diff --git a/phpunit.xml b/phpunit.xml
index 3c5301d6..0f04b5f6 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -6,13 +6,6 @@
cacheResult="false"
colors="true"
>
-
-
-
-
-
-
-
diff --git a/src/Operation.php b/src/Operation.php
index 2d96d375..ab4aaf8f 100644
--- a/src/Operation.php
+++ b/src/Operation.php
@@ -14,22 +14,35 @@ abstract class Operation
*
* If true, then it will be executed once.
* If false, then the operation will run every time the `operations` command is invoked.
+ *
+ * @deprecated Will be removed in 7.x version. Use `shouldOnce` method instead.
*/
protected bool $once = true;
/**
* Determines which environment to run on.
+ *
+ * @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
*/
protected array|string|null $environment = null;
/**
* Determines in which environment it should not run.
+ *
+ * @deprecated Will be removed in 7.x version. Use `exceptEnvironment` method instead.
*/
protected array|string|null $exceptEnvironment = null;
- /** Defines a possible "pre-launch" of the operation. */
+ /**
+ * Defines a possible "pre-launch" of the operation.
+ *
+ * @deprecated Will be removed in 7.x version. Use `hasBefore` method instead.
+ */
protected bool $before = true;
+ /**
+ * @deprecated
+ */
public function getConnection(): ?string
{
return config('deploy-operations.connection');
@@ -40,22 +53,47 @@ public function getConnection(): ?string
*
* If true, then it will be executed once.
* If false, then the operation will run every time the `operations` command is invoked.
+ *
+ * @deprecated Will be removed in 7.x version. Use `shouldOnce` method instead.
*/
public function isOnce(): bool
{
return $this->once;
}
+ /**
+ * Determines the type of launch of the deploy operation.
+ *
+ * If true, then it will be executed once.
+ * If false, then the operation will run every time the `operations` command is invoked.
+ */
+ public function shouldOnce(): bool
+ {
+ return $this->isOnce();
+ }
+
/**
* Determines a call to database transactions.
+ *
+ * @deprecated Will be removed in 7.x version. Use `withinTransactions` method instead.
*/
public function enabledTransactions(): bool
{
return (bool) config('deploy-operations.transactions.enabled');
}
+ /**
+ * Determines a call to database transactions.
+ */
+ public function withinTransactions(): bool
+ {
+ return $this->enabledTransactions();
+ }
+
/**
* The number of attempts to execute a request within a transaction before throwing an error.
+ *
+ * @deprecated Will be removed in 7.x version. Set the value in the `config/deploy-operations.php` settings file.
*/
public function transactionAttempts(): int
{
@@ -64,14 +102,25 @@ public function transactionAttempts(): int
/**
* Determines which environment to run on.
+ *
+ * @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
*/
public function onEnvironment(): array
{
return Arr::wrap($this->environment);
}
+ public function withinEnvironment(): bool
+ {
+ $env = $this->onEnvironment();
+
+ return empty($env) || in_array(app()->environment(), $env, true);
+ }
+
/**
* Determines in which environment it should not run.
+ *
+ * @deprecated Since with version 7.0 will return `bool`.
*/
public function exceptEnvironment(): array
{
@@ -80,28 +129,58 @@ public function exceptEnvironment(): array
/**
* Determines whether the given operation can be called conditionally.
+ *
+ * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
*/
public function allow(): bool
{
return true;
}
+ /**
+ * Determines whether the given operation can be called conditionally.
+ */
+ public function shouldRun(): bool
+ {
+ return $this->allow();
+ }
+
/**
* Defines a possible "pre-launch" of the operation.
+ *
+ * @deprecated Will be removed in 7.x version. Use `needBefore` method instead.
*/
public function hasBefore(): bool
{
return $this->before;
}
+ /**
+ * Defines a possible "pre-launch" of the operation.
+ */
+ public function needBefore(): bool
+ {
+ return $this->hasBefore();
+ }
+
/**
* Defines whether the operation will run synchronously or asynchronously.
+ *
+ * @deprecated Will be removed in 7.x version. Use `shouldBeAsync` method instead.
*/
public function isAsync(): bool
{
return (bool) config('deploy-operations.async');
}
+ /**
+ * Defines whether the operation will run synchronously or asynchronously.
+ */
+ public function shouldBeAsync(): bool
+ {
+ return $this->isAsync();
+ }
+
/**
* Method to be called when the job completes successfully.
*/
diff --git a/src/Services/Migrator.php b/src/Services/Migrator.php
index dfe74283..0b41091a 100644
--- a/src/Services/Migrator.php
+++ b/src/Services/Migrator.php
@@ -71,7 +71,7 @@ public function runUp(string $filename, int $batch, Options $options): void
? $this->runOperation($operation, '__invoke')
: $this->runOperation($operation, 'up');
- if ($this->allowLogging($operation)) {
+ if ($operation->shouldOnce()) {
$this->log($name, $batch);
}
});
@@ -96,7 +96,7 @@ protected function runOperation(Operation $operation, string $method): void
$this->runMethod(
$operation,
$method,
- $operation->enabledTransactions(),
+ $operation->withinTransactions(),
$operation->transactionAttempts()
);
@@ -117,7 +117,7 @@ protected function hasOperation(Operation $operation, string $method): bool
protected function hasAsync(Operation $operation, Options $options): bool
{
- return ! $options->sync && $operation->isAsync();
+ return ! $options->sync && $operation->shouldBeAsync();
}
protected function runMethod(Operation $operation, string $method, bool $transactions, int $attempts): void
@@ -150,29 +150,22 @@ protected function allowEnvironment(Operation $operation): bool
{
$env = $this->config->environment();
- return $operation->allow()
- && $this->onEnvironment($env, $operation->onEnvironment())
+ return $operation->shouldRun()
+ && $operation->withinEnvironment()
&& $this->exceptEnvironment($env, $operation->exceptEnvironment());
}
- protected function onEnvironment(?string $env, array $on): bool
- {
- return empty($on) || in_array($env, $on);
- }
-
+ /**
+ * @deprecated
+ */
protected function exceptEnvironment(?string $env, array $except): bool
{
- return empty($except) || ! in_array($env, $except);
+ return empty($except) || ! in_array($env, $except, true);
}
protected function disallowBefore(Operation $operation, Options $options): bool
{
- return $options->before && ! $operation->hasBefore();
- }
-
- protected function allowLogging(Operation $operation): bool
- {
- return $operation->isOnce();
+ return $options->before && ! $operation->needBefore();
}
protected function resolvePath(string $filename, string $path): string