DeleteStorableFile::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 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