DeleteStorableFile   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 6 1
1
<?php
2
3
namespace Gurgentil\LaravelStorable\Services;
4
5
use Gurgentil\LaravelStorable\Contracts\Storable;
6
use Illuminate\Support\Facades\Config;
7
use Illuminate\Support\Facades\Storage;
8
9
class DeleteStorableFile
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $disk;
15
16
    /**
17
     * GenerateStorableFile constructor.
18
     *
19
     * @param string|null $disk
20
     */
21
    public function __construct(?string $disk = null)
22
    {
23
        $this->disk = $disk ?? Config::get('storable.disk');
24
    }
25
26
    /**
27
     * Remove file from storage.
28
     *
29
     * @param Storable $storable
30
     */
31
    public function handle(Storable $storable): void
32
    {
33
        $path = $storable->getFilePath();
34
35
        Storage::disk($this->disk)
36
            ->delete($path);
37
    }
38
}
39