factoryService = $factoryService; parent::__construct(); } /** * Execute the console command. */ public function handle() { $this->info("Start"); $type = $this->argument('type'); $batch = $this->argument('batch'); $job = $this->argument('job'); $tmdbId = $this->argument('tmdbId'); $items = $this->getBatch($type, $batch, $job, $tmdbId); $this->info("Processing ".count($items)." items of type `{$type}`."); $this->processItems($items, $job, $type); $this->info("Fin."); } private function getBatch(string $type, int $batch, string $job, int $tmdbId = null) { switch ($type){ case ItemToFetch::TYPE_MOVIE: return MovieProcessingService::getBatch($batch, $job); case ItemToFetch::TYPE_TV_SERIES: return ShowProcessingService::getBatch($batch, $job, $tmdbId); } } private function processItems(\Illuminate\Database\Eloquent\Collection $items, $job, $type) { $bar = $this->output->createProgressBar(count($items)); foreach ($items as $item) { $this->processItem($item, $job, $type); $bar->advance(); } $bar->finish(); } private function processItem($item, $job, $type) { $this->factoryService->process($item, $job, $type); } }