| Total Complexity | 3 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class Import |
||
| 15 | { |
||
| 16 | use Queueable; |
||
| 17 | use ProgressReportable; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var ImportSource |
||
| 21 | */ |
||
| 22 | private $source; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param ImportSource $source |
||
| 26 | */ |
||
| 27 | 13 | public function __construct(ImportSource $source) |
|
| 28 | { |
||
| 29 | 13 | $this->source = $source; |
|
| 30 | 13 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @param Client $elasticsearch |
||
| 34 | */ |
||
| 35 | 13 | public function handle(Client $elasticsearch): void |
|
| 36 | { |
||
| 37 | 13 | $stages = $this->stages(); |
|
| 38 | 13 | $estimate = $stages->sum->estimate(); |
|
| 39 | 13 | $this->progressBar()->setMaxSteps($estimate); |
|
| 40 | $stages->each(function ($stage) use ($elasticsearch) { |
||
| 41 | 13 | $this->progressBar()->setMessage($stage->title()); |
|
| 42 | 13 | $stage->handle($elasticsearch); |
|
| 43 | 13 | $this->progressBar()->advance($stage->estimate()); |
|
| 44 | 13 | }); |
|
| 45 | 13 | } |
|
| 46 | |||
| 47 | 13 | private function stages(): Collection |
|
| 50 | } |
||
| 51 | } |
||
| 52 |