Completed
Push — master ( 3ee920...44cf32 )
by Pascal
02:41
created

Disk   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromName() 0 6 1
A isLocal() 0 6 1
A newFile() 0 4 1
A getPath() 0 4 1
A __call() 0 4 1
1
<?php
2
3
namespace Pbmedia\LaravelFFMpeg;
4
5
use Illuminate\Contracts\Filesystem\Filesystem;
6
use League\Flysystem\Adapter\Local as LocalAdapater;
7
8
class Disk
9
{
10
    protected $disk;
11
12
    protected static $filesystems;
13
14
    public function __construct(Filesystem $disk)
15
    {
16
        $this->disk = $disk;
17
    }
18
19
    public static function fromName(string $name): self
20
    {
21
        $adapter = FFMpeg::getFilesystems()->disk($name);
22
23
        return new static($adapter);
24
    }
25
26
    public function isLocal(): bool
27
    {
28
        $adapter = $this->disk->getDriver()->getAdapter();
29
30
        return $adapter instanceof LocalAdapater;
31
    }
32
33
    public function newFile(string $path): File
34
    {
35
        return new File($this, $path);
36
    }
37
38
    public function getPath(): string
39
    {
40
        return $this->disk->getDriver()->getAdapter()->getPathPrefix();
41
    }
42
43
    public function __call($method, $parameters)
44
    {
45
        return call_user_func_array([$this->disk, $method], $parameters);
46
    }
47
}
48