Passed
Pull Request — master (#12)
by Dmitriy
02:17
created

Filesystem::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 4
dl 0
loc 9
ccs 0
cts 8
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Yiisoft\Files;
4
5
use League\Flysystem\Filesystem as LeagueFilesystem;
6
use League\Flysystem\FilesystemAdapter;
7
use League\Flysystem\PathNormalizer;
8
use Yiisoft\Aliases\Aliases;
9
10
class Filesystem extends LeagueFilesystem implements FilesystemInterface
11
{
12
    private Aliases $aliases;
13
14
    public function __construct(FilesystemAdapter $adapter, array $aliases = [], array $config = [], PathNormalizer $pathNormalizer = null)
15
    {
16
        if ($aliases !== []) {
17
            $aliases = array_merge(['@root' => ''], $aliases);
18
            $aliases['@root'] = '';
19
        }
20
        $this->aliases = new Aliases($aliases);
21
22
        parent::__construct($adapter, $config, $pathNormalizer);
23
    }
24
25
    public function fileExists(string $location): bool
26
    {
27
        $location = $this->aliases->get($location);
28
        return parent::fileExists($location);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::fileExists() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
        return parent::fileExists(/** @scrutinizer ignore-type */ $location);
Loading history...
29
    }
30
31
    public function write(string $location, string $contents, array $config = []): void
32
    {
33
        $location = $this->aliases->get($location);
34
        parent::write($location, $contents, $config);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::write() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

34
        parent::write(/** @scrutinizer ignore-type */ $location, $contents, $config);
Loading history...
35
    }
36
37
    public function writeStream(string $location, $contents, array $config = []): void
38
    {
39
        $location = $this->aliases->get($location);
40
        parent::writeStream($location, $contents, $config);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::writeStream() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        parent::writeStream(/** @scrutinizer ignore-type */ $location, $contents, $config);
Loading history...
41
    }
42
43
    public function read(string $location): string
44
    {
45
        $location = $this->aliases->get($location);
46
        return parent::read($location);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::read() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
        return parent::read(/** @scrutinizer ignore-type */ $location);
Loading history...
47
    }
48
49
    public function readStream(string $location)
50
    {
51
        $location = $this->aliases->get($location);
52
        return parent::readStream($location);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::readStream() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

52
        return parent::readStream(/** @scrutinizer ignore-type */ $location);
Loading history...
53
    }
54
55
    public function delete(string $location): void
56
    {
57
        $location = $this->aliases->get($location);
58
        parent::delete($location);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::delete() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
        parent::delete(/** @scrutinizer ignore-type */ $location);
Loading history...
59
    }
60
61
    public function createDirectory(string $location, array $config = []): void
62
    {
63
        $location = $this->aliases->get($location);
64
        parent::createDirectory($location, $config);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::createDirectory() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
        parent::createDirectory(/** @scrutinizer ignore-type */ $location, $config);
Loading history...
65
    }
66
67
    public function deleteDirectory(string $location): void
68
    {
69
        $location = $this->aliases->get($location);
70
        parent::deleteDirectory($location);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::deleteDirectory() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

70
        parent::deleteDirectory(/** @scrutinizer ignore-type */ $location);
Loading history...
71
    }
72
73
    public function copy(string $source, string $destination, array $config = []): void
74
    {
75
        $source = $this->aliases->get($source);
76
        $destination = $this->aliases->get($destination);
77
        parent::copy($source, $destination, $config);
0 ignored issues
show
Bug introduced by
It seems like $source can also be of type boolean; however, parameter $source of League\Flysystem\Filesystem::copy() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

77
        parent::copy(/** @scrutinizer ignore-type */ $source, $destination, $config);
Loading history...
Bug introduced by
It seems like $destination can also be of type boolean; however, parameter $destination of League\Flysystem\Filesystem::copy() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

77
        parent::copy($source, /** @scrutinizer ignore-type */ $destination, $config);
Loading history...
78
    }
79
80
    public function move(string $source, string $destination, array $config = []): void
81
    {
82
        $source = $this->aliases->get($source);
83
        $destination = $this->aliases->get($destination);
84
        parent::move($source, $destination, $config);
0 ignored issues
show
Bug introduced by
It seems like $source can also be of type boolean; however, parameter $source of League\Flysystem\Filesystem::move() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

84
        parent::move(/** @scrutinizer ignore-type */ $source, $destination, $config);
Loading history...
Bug introduced by
It seems like $destination can also be of type boolean; however, parameter $destination of League\Flysystem\Filesystem::move() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

84
        parent::move($source, /** @scrutinizer ignore-type */ $destination, $config);
Loading history...
85
    }
86
87
    public function setVisibility(string $path, string $visibility): void
88
    {
89
        $path = $this->aliases->get($path);
90
        parent::setVisibility($path, $visibility);
0 ignored issues
show
Bug introduced by
It seems like $path can also be of type boolean; however, parameter $path of League\Flysystem\Filesystem::setVisibility() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

90
        parent::setVisibility(/** @scrutinizer ignore-type */ $path, $visibility);
Loading history...
91
    }
92
93
    public function visibility(string $path): string
94
    {
95
        $path = $this->aliases->get($path);
96
        return parent::visibility($path);
0 ignored issues
show
Bug introduced by
It seems like $path can also be of type boolean; however, parameter $path of League\Flysystem\Filesystem::visibility() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

96
        return parent::visibility(/** @scrutinizer ignore-type */ $path);
Loading history...
97
    }
98
99
    public function mimeType(string $path): string
100
    {
101
        $path = $this->aliases->get($path);
102
        return parent::mimeType($path);
0 ignored issues
show
Bug introduced by
It seems like $path can also be of type boolean; however, parameter $path of League\Flysystem\Filesystem::mimeType() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

102
        return parent::mimeType(/** @scrutinizer ignore-type */ $path);
Loading history...
103
    }
104
105
    public function lastModified(string $path): int
106
    {
107
        $path = $this->aliases->get($path);
108
        return parent::lastModified($path);
0 ignored issues
show
Bug introduced by
It seems like $path can also be of type boolean; however, parameter $path of League\Flysystem\Filesystem::lastModified() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

108
        return parent::lastModified(/** @scrutinizer ignore-type */ $path);
Loading history...
109
    }
110
111
    public function listContents(string $location, bool $deep = LeagueFilesystem::LIST_SHALLOW): \League\Flysystem\DirectoryListing
112
    {
113
        $location = $this->aliases->get($location);
114
        return parent::listContents($location, $deep);
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $location of League\Flysystem\Filesystem::listContents() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

114
        return parent::listContents(/** @scrutinizer ignore-type */ $location, $deep);
Loading history...
115
    }
116
117
    public function fileSize(string $path): int
118
    {
119
        $path = $this->aliases->get($path);
120
        return parent::fileSize($path);
0 ignored issues
show
Bug introduced by
It seems like $path can also be of type boolean; however, parameter $path of League\Flysystem\Filesystem::fileSize() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

120
        return parent::fileSize(/** @scrutinizer ignore-type */ $path);
Loading history...
121
    }
122
}
123