Skip to content

Method shouldBeAsync was renamed with needAsync #207

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
Apr 2, 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
2 changes: 1 addition & 1 deletion src/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function needBefore(): bool
/**
* Defines whether the operation will run synchronously or asynchronously.
*/
public function shouldBeAsync(): bool
public function needAsync(): bool
{
return app(ConfigData::class)->async;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Services/MigratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function runUp(string $filename, int $batch, OptionsData $options): void
return;
}

if ($this->hasAsync($operation, $options)) {
if ($this->needAsync($operation, $options)) {
OperationJob::dispatch($name);

$this->notification->twoColumn($name, StatusEnum::Pending->toColor());
Expand All @@ -69,7 +69,7 @@ public function runUp(string $filename, int $batch, OptionsData $options): void
}

$this->notification->task($name, function () use ($operation, $name, $batch) {
$this->hasOperation($operation, '__invoke')
$this->hasMethod($operation, '__invoke')
? $this->runOperation($operation, '__invoke')
: $this->runOperation($operation, 'up');

Expand All @@ -93,7 +93,7 @@ public function runDown(string $filename, OptionsData $options): void

protected function runOperation(Operation $operation, string $method): void
{
if ($this->hasOperation($operation, $method)) {
if ($this->hasMethod($operation, $method)) {
try {
$this->runMethod($operation, $method, $operation->withinTransactions());

Expand All @@ -107,14 +107,14 @@ protected function runOperation(Operation $operation, string $method): void
}
}

protected function hasOperation(Operation $operation, string $method): bool
protected function hasMethod(Operation $operation, string $method): bool
{
return method_exists($operation, $method);
}

protected function hasAsync(Operation $operation, OptionsData $options): bool
protected function needAsync(Operation $operation, OptionsData $options): bool
{
return ! $options->sync && $operation->shouldBeAsync();
return ! $options->sync && $operation->needAsync();
}

protected function runMethod(Operation $operation, string $method, bool $transactions): void
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/app/async/2021_04_06_212742_every_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function shouldOnce(): bool
return false;
}

public function shouldBeAsync(): bool
public function needAsync(): bool
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/app/async/2023_04_06_212637_foo_bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function table(): Builder
return DB::table('test');
}

public function shouldBeAsync(): bool
public function needAsync(): bool
{
return true;
}
Expand Down