♻️ Dependency injection

This commit is contained in:
Dan Jones 2023-06-22 18:59:19 -05:00
commit 1295b03c3a
2 changed files with 4 additions and 4 deletions

View file

@ -11,11 +11,11 @@ class TraktWatch extends Command
protected $signature = 'show:watch {file : File to watch}'; protected $signature = 'show:watch {file : File to watch}';
protected $description = 'Mark a show as watched right now on Trakt'; protected $description = 'Mark a show as watched right now on Trakt';
public function handle(): int public function handle(Trakt $trakt): int
{ {
$file = WatchFile::from($this->argument('file')); $file = WatchFile::from($this->argument('file'));
$data = WatchData::from(['rawData' => [$file->toArray()]]); $data = WatchData::from(['rawData' => [$file->toArray()]]);
$resp = $this->app->make(Trakt::class)->syncHistory($data, $this->output); $resp = $trakt->syncHistory($data, $this->output);
return $resp->ok() ? static::SUCCESS : static::FAILURE; return $resp->ok() ? static::SUCCESS : static::FAILURE;
} }

View file

@ -10,10 +10,10 @@ class TraktWatchImport extends Command
protected $signature = 'show:watch:import {files* : JSON files to import}'; protected $signature = 'show:watch:import {files* : JSON files to import}';
protected $description = 'Once online, sync watches from show:watch:export'; protected $description = 'Once online, sync watches from show:watch:export';
public function handle(): int public function handle(Trakt $trakt): int
{ {
$watched = WatchData::from($this->arguments()); $watched = WatchData::from($this->arguments());
$resp = $this->app->make(Trakt::class)->syncHistory($watched, $this->output); $resp = $trakt->syncHistory($watched, $this->output);
return $resp->ok() ? static::SUCCESS : static::FAILURE; return $resp->ok() ? static::SUCCESS : static::FAILURE;
} }