Completed
Push — master ( a5450c...7ec76e )
by ReliQ
09:15 queued 10s
created

DumpImageCache   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 12 2
1
<?php
2
3
namespace ReliqArts\GuidedImage\Console\Commands;
4
5
use File;
6
use Illuminate\Config\Repository as Config;
7
use Illuminate\Console\Command;
8
9
class DumpImageCache extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'guidedimage:clear';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Empty guided image file cache';
24
25
    /**
26
     * Guided image cache directory.
27
     */
28
    protected $skimDir;
29
30
    /**
31
     * Create a new command instance.
32
     */
33
    public function __construct()
34
    {
35
        parent::__construct();
36
    }
37
38
    /**
39
     * Execute the console command.
40
     */
41
    public function handle(Config $config): void
42
    {
43
        $this->skimDir = storage_path($config->get('guidedimage.storage.skim_dir'));
44
45
        // remove skim dir
46
        if (File::isDirectory($this->skimDir)) {
47
            File::deleteDirectory($this->skimDir, true);
48
            $this->line(PHP_EOL . '<info>✔</info> Success! Guided image cache cleared.');
49
        } else {
50
            $this->line(PHP_EOL . '<info>✔</info> It wasn\'t there! Guided image cache directory does not exist.');
51
        }
52
    }
53
}
54