UploadEntityFileSystem   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A driverIsNotLocal() 0 3 1
A disk() 0 5 1
A folder() 0 7 2
A driverIsLocal() 0 3 1
1
<?php
2
3
namespace Mostafaznv\Larupload\Concerns\Storage\UploadEntity;
4
5
6
use Illuminate\Support\Str;
7
use Mostafaznv\Larupload\UploadEntities;
8
9
trait UploadEntityFileSystem
10
{
11
    protected string $folder = '';
12
13
    protected string $disk;
14
15
    protected string $localDisk;
16
17
18
    public function folder(string $name): UploadEntities
19
    {
20
        if (!$this->folder) {
21
            $this->folder = str_replace('_', '-', Str::kebab($name));
22
        }
23
24
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityFileSystem which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
25
    }
26
27
    public function disk(string $disk): UploadEntities
28
    {
29
        $this->disk = $disk;
30
31
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Mostafaznv\Larupload\Con...\UploadEntityFileSystem which includes types incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities.
Loading history...
32
    }
33
34
    protected function driverIsLocal(): bool
35
    {
36
        return disk_driver_is_local($this->disk);
37
    }
38
39
    protected function driverIsNotLocal(): bool
40
    {
41
        return !$this->driverIsLocal();
42
    }
43
}
44