Completed
Push — master ( 42e4d6...a002fc )
by Pascal
02:56
created

Disk::createDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
/**
9
 * @method bool put($path, $contents, $visibility = null)
10
 */
11
class Disk
12
{
13
    protected $disk;
14
15
    protected static $filesystems;
16
17
    public function __construct(Filesystem $disk)
18
    {
19
        $this->disk = $disk;
20
    }
21
22
    public static function fromName(string $name): Disk
23
    {
24
        $adapter = FFMpeg::getFilesystems()->disk($name);
25
26
        return new static($adapter);
27
    }
28
29
    public function isLocal(): bool
30
    {
31
        $adapter = $this->disk->getDriver()->getAdapter();
32
33
        return $adapter instanceof LocalAdapater;
34
    }
35
36
    public function newFile(string $path): File
37
    {
38
        return new File($this, $path);
39
    }
40
41
    public function getPath(): string
42
    {
43
        return $this->disk->getDriver()->getAdapter()->getPathPrefix();
44
    }
45
46
    public function createDirectory(string $path)
47
    {
48
        return $this->disk->makeDirectory($path);
49
    }
50
51
    public function __call($method, $parameters)
52
    {
53
        return call_user_func_array([$this->disk, $method], $parameters);
54
    }
55
}
56