diff --git a/src/Jobs/Import.php b/src/Jobs/Import.php index 92c76045..026e5737 100644 --- a/src/Jobs/Import.php +++ b/src/Jobs/Import.php @@ -5,6 +5,7 @@ use Elastic\Elasticsearch\Client; use Illuminate\Bus\Queueable; use Illuminate\Support\Collection; +use Matchish\ScoutElasticSearch\Jobs\Stages\StageInterface; use Matchish\ScoutElasticSearch\ProgressReportable; use Matchish\ScoutElasticSearch\Searchable\ImportSource; @@ -40,6 +41,7 @@ public function handle(Client $elasticsearch): void $estimate = $stages->sum->estimate(); $this->progressBar()->setMaxSteps($estimate); $stages->each(function ($stage) use ($elasticsearch) { + /** @var StageInterface $stage */ $this->progressBar()->setMessage($stage->title()); $stage->handle($elasticsearch); $this->progressBar()->advance($stage->estimate()); diff --git a/src/Jobs/Stages/CleanUp.php b/src/Jobs/Stages/CleanUp.php index 2f6af041..da674c9d 100644 --- a/src/Jobs/Stages/CleanUp.php +++ b/src/Jobs/Stages/CleanUp.php @@ -11,7 +11,7 @@ /** * @internal */ -final class CleanUp +final class CleanUp implements StageInterface { /** * @var ImportSource diff --git a/src/Jobs/Stages/CreateWriteIndex.php b/src/Jobs/Stages/CreateWriteIndex.php index 98612f15..1db3b48d 100644 --- a/src/Jobs/Stages/CreateWriteIndex.php +++ b/src/Jobs/Stages/CreateWriteIndex.php @@ -13,7 +13,7 @@ /** * @internal */ -final class CreateWriteIndex +final class CreateWriteIndex implements StageInterface { /** * @var ImportSource diff --git a/src/Jobs/Stages/PullFromSource.php b/src/Jobs/Stages/PullFromSource.php index 283cbd8f..6e6a7c5e 100644 --- a/src/Jobs/Stages/PullFromSource.php +++ b/src/Jobs/Stages/PullFromSource.php @@ -2,13 +2,14 @@ namespace Matchish\ScoutElasticSearch\Jobs\Stages; +use Elastic\Elasticsearch\Client; use Illuminate\Support\Collection; use Matchish\ScoutElasticSearch\Searchable\ImportSource; /** * @internal */ -final class PullFromSource +final class PullFromSource implements StageInterface { /** * @var ImportSource @@ -23,7 +24,7 @@ public function __construct(ImportSource $source) $this->source = $source; } - public function handle(): void + public function handle(Client $elasticsearch = null): void { $results = $this->source->get()->filter->shouldBeSearchable(); if (! $results->isEmpty()) { diff --git a/src/Jobs/Stages/RefreshIndex.php b/src/Jobs/Stages/RefreshIndex.php index 86a46d7e..6a9e7aae 100644 --- a/src/Jobs/Stages/RefreshIndex.php +++ b/src/Jobs/Stages/RefreshIndex.php @@ -9,7 +9,7 @@ /** * @internal */ -final class RefreshIndex +final class RefreshIndex implements StageInterface { /** * @var Index diff --git a/src/Jobs/Stages/StageInterface.php b/src/Jobs/Stages/StageInterface.php new file mode 100644 index 00000000..08c5399a --- /dev/null +++ b/src/Jobs/Stages/StageInterface.php @@ -0,0 +1,12 @@ +