RefreshThumbnailCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A fire() 0 10 2
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