RefreshThumbnailCommand::fire()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4286
cc 2
eloc 5
nc 2
nop 0
1
<?php namespace Modules\Media\Console;
2
3
use Illuminate\Console\Command;
4
use Modules\Media\Image\Imagy;
5
use Modules\Media\Repositories\FileRepository;
6
7
class RefreshThumbnailCommand extends Command
8
{
9
    protected $name = 'asgard:media:refresh';
10
    protected $description = 'Create and or refresh the thumbnails';
11
    /**
12
     * @var Imagy
13
     */
14
    private $imagy;
15
    /**
16
     * @var FileRepository
17
     */
18
    private $file;
19
20
    public function __construct(Imagy $imagy, FileRepository $file)
21
    {
22
        parent::__construct();
23
        $this->imagy = $imagy;
24
        $this->file = $file;
25
    }
26
27
    /**
28
     * Execute the console command.
29
     *
30
     * @return mixed
31
     */
32
    public function fire()
33
    {
34
        $this->line('Preparing to regenerate all thumbnails...');
35
36
        foreach ($this->file->all() as $file) {
37
            $this->imagy->createAll($file->path);
38
        }
39
40
        $this->info('All thumbnails refreshed');
41
    }
42
}
43