Skip to content

Renamed withinEnvironment with shouldBeEnvironment #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ abstract class Operation
/**
* Determines which environment to run on.
*
* @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
* @deprecated Will be removed in 7.x version. Use `shouldEnvironment` 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.
* @deprecated Will be removed in 7.x version. Use `shouldEnvironment` method instead.
*/
protected array|string|null $exceptEnvironment = null;

Expand Down Expand Up @@ -103,30 +103,30 @@ public function transactionAttempts(): int
/**
* Determines which environment to run on.
*
* @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
* @deprecated Will be removed in 7.x version. Use `shouldEnvironment` 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`.
* @deprecated Will be removed in 7.x version. Use `shouldEnvironment` method instead.
*/
public function exceptEnvironment(): array
{
return Arr::wrap($this->exceptEnvironment);
}

public function shouldBeEnvironment(): bool
{
$env = $this->onEnvironment();

return empty($env) || in_array(app()->environment(), $env, true);
}

/**
* Determines whether the given operation can be called conditionally.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected function allowEnvironment(Operation $operation): bool
$env = $this->config->environment();

return $operation->shouldRun()
&& $operation->withinEnvironment()
&& $operation->shouldBeEnvironment()
&& $this->exceptEnvironment($env, $operation->exceptEnvironment());
}

Expand Down