EmptyCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 12
c 1
b 0
f 1
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 3
1
<?php
2
3
namespace Arubacao\AssetCdn\Commands;
4
5
use Illuminate\Config\Repository;
6
use Illuminate\Filesystem\FilesystemManager;
7
8
class EmptyCommand extends BaseCommand
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'asset-cdn:empty';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Deletes assets on CDN';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @param FilesystemManager $filesystemManager
28
     * @param Repository $config
29
     *
30
     * @return void
31
     */
32
    public function handle(FilesystemManager $filesystemManager, Repository $config)
33
    {
34
        $filesystem = $config->get('asset-cdn.filesystem.disk');
35
        $filesOnCdn = $filesystemManager
36
            ->disk($filesystem)
37
            ->allFiles();
38
39
        if ($filesystemManager
40
            ->disk($filesystem)
41
            ->delete($filesOnCdn)) {
42
            foreach ($filesOnCdn as $file) {
43
                $this->info("Successfully deleted: {$file}");
44
            }
45
        }
46
    }
47
}
48