Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 17 |
CRAP | |
0.00% |
0 / 1 |
| FlyWrapperTrait | |
0.00% |
0 / 17 |
|
0.00% |
0 / 17 |
306 | |
0.00% |
0 / 1 |
| write | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| writeStream | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| move | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| copy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| delete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| deleteDirectory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| createDirectory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setVisibility | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| fileExists | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| directoryExists | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| read | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| readStream | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| listContents | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| fileSize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| mimeType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| lastModified | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| visibility | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAdapter | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | |
| 3 | namespace oat\oatbox\filesystem\utils; |
| 4 | |
| 5 | use League\Flysystem\FileAttributes; |
| 6 | use League\Flysystem\FilesystemAdapter; |
| 7 | use League\Flysystem\Config; |
| 8 | |
| 9 | /** |
| 10 | * A trait to facilitate creation of adapter wrappers |
| 11 | * |
| 12 | * @author Joel Bout |
| 13 | */ |
| 14 | trait FlyWrapperTrait |
| 15 | { |
| 16 | /** |
| 17 | * @see FilesystemAdapter::write() |
| 18 | * @inheritDoc |
| 19 | */ |
| 20 | public function write(string $path, string $contents, Config $config): void |
| 21 | { |
| 22 | $this->getAdapter()->write($path, $contents, $config); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @see FilesystemAdapter::writeStream() |
| 27 | * @inheritDoc |
| 28 | */ |
| 29 | public function writeStream(string $path, $contents, Config $config): void |
| 30 | { |
| 31 | $this->getAdapter()->writeStream($path, $contents, $config); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @see FilesystemAdapter::move() |
| 36 | * @inheritDoc |
| 37 | */ |
| 38 | public function move(string $source, string $destination, Config $config): void |
| 39 | { |
| 40 | $this->getAdapter()->move($source, $destination, $config); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @see FilesystemAdapter::copy() |
| 45 | * @inheritDoc |
| 46 | */ |
| 47 | public function copy(string $source, string $destination, Config $config): void |
| 48 | { |
| 49 | $this->getAdapter()->copy($source, $destination, $config); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @see FilesystemAdapter::delete() |
| 54 | * @inheritDoc |
| 55 | */ |
| 56 | public function delete(string $path): void |
| 57 | { |
| 58 | $this->getAdapter()->delete($path); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @see FilesystemAdapter::deleteDirectory() |
| 63 | * @inheritDoc |
| 64 | */ |
| 65 | public function deleteDirectory(string $path): void |
| 66 | { |
| 67 | $this->getAdapter()->deleteDirectory($path); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @see FilesystemAdapter::createDirectory() |
| 72 | * @inheritDoc |
| 73 | */ |
| 74 | public function createDirectory(string $path, Config $config): void |
| 75 | { |
| 76 | $this->getAdapter()->createDirectory($path, $config); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * @see FilesystemAdapter::setVisibility() |
| 81 | * @inheritDoc |
| 82 | */ |
| 83 | public function setVisibility(string $path, string $visibility): void |
| 84 | { |
| 85 | $this->getAdapter()->setVisibility($path, $visibility); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @see FilesystemAdapter::fileExists() |
| 90 | * @inheritDoc |
| 91 | */ |
| 92 | public function fileExists(string $path): bool |
| 93 | { |
| 94 | return $this->getAdapter()->fileExists($path); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @see FilesystemAdapter::directoryExists() |
| 99 | * @inheritDoc |
| 100 | */ |
| 101 | public function directoryExists(string $path): bool |
| 102 | { |
| 103 | return $this->getAdapter()->directoryExists($path); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @see FilesystemAdapter::read() |
| 108 | * @inheritDoc |
| 109 | */ |
| 110 | public function read(string $path): string |
| 111 | { |
| 112 | return $this->getAdapter()->read($path); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * @see FilesystemAdapter::readStream() |
| 117 | * @inheritDoc |
| 118 | */ |
| 119 | public function readStream($path) |
| 120 | { |
| 121 | return $this->getAdapter()->readStream($path); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @see FilesystemAdapter::listContents() |
| 126 | * @inheritDoc |
| 127 | */ |
| 128 | public function listContents(string $path, bool $deep = false): iterable |
| 129 | { |
| 130 | return $this->getAdapter()->listContents($path, $deep); |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @see FilesystemAdapter::fileSize() |
| 135 | * @inheritDoc |
| 136 | */ |
| 137 | public function fileSize(string $path): FileAttributes |
| 138 | { |
| 139 | return $this->getAdapter()->fileSize($path); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * @see FilesystemAdapter::mimeType() |
| 144 | * @inheritDoc |
| 145 | */ |
| 146 | public function mimeType(string $path): FileAttributes |
| 147 | { |
| 148 | return $this->getAdapter()->mimeType($path); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * @see FilesystemAdapter::lastModified() |
| 153 | * @inheritDoc |
| 154 | */ |
| 155 | public function lastModified(string $path): FileAttributes |
| 156 | { |
| 157 | return $this->getAdapter()->lastModified($path); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * @see FilesystemAdapter::visibility() |
| 162 | * @inheritDoc |
| 163 | */ |
| 164 | public function visibility(string $path): FileAttributes |
| 165 | { |
| 166 | return $this->getAdapter()->visibility($path); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Return the adapter implementation |
| 171 | * |
| 172 | * @return FilesystemAdapter |
| 173 | */ |
| 174 | abstract public function getAdapter(); |
| 175 | } |