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

Disk::fromName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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