@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | * Class Filesystem |
| 55 | 55 | * @package Platine\Filesystem |
| 56 | 56 | */ |
| 57 | -class Filesystem |
|
| 58 | -{ |
|
| 57 | +class Filesystem { |
|
| 59 | 58 | /** |
| 60 | 59 | * The adapter instance |
| 61 | 60 | * @var AdapterInterface |
@@ -66,8 +65,7 @@ discard block |
||
| 66 | 65 | * Create new instance |
| 67 | 66 | * @param AdapterInterface|null $adapter |
| 68 | 67 | */ |
| 69 | - public function __construct(?AdapterInterface $adapter = null) |
|
| 70 | - { |
|
| 68 | + public function __construct(?AdapterInterface $adapter = null) { |
|
| 71 | 69 | $this->adapter = $adapter ?? new LocalAdapter(); |
| 72 | 70 | } |
| 73 | 71 | |
@@ -85,8 +83,7 @@ discard block |
||
| 85 | 83 | * @param string $path |
| 86 | 84 | * @return FileInterface|DirectoryInterface|null |
| 87 | 85 | */ |
| 88 | - public function get(string $path) |
|
| 89 | - { |
|
| 86 | + public function get(string $path) { |
|
| 90 | 87 | return $this->adapter->get($path); |
| 91 | 88 | } |
| 92 | 89 | |
@@ -53,8 +53,7 @@ |
||
| 53 | 53 | * Class FilesystemInterface |
| 54 | 54 | * @package Platine\Filesystem |
| 55 | 55 | */ |
| 56 | -interface FilesystemInterface |
|
| 57 | -{ |
|
| 56 | +interface FilesystemInterface { |
|
| 58 | 57 | /** |
| 59 | 58 | * Whether the file system is a file |
| 60 | 59 | * @return bool |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | * Class FileInterface |
| 52 | 52 | * @package Platine\Filesystem |
| 53 | 53 | */ |
| 54 | -interface FileInterface extends FilesystemInterface |
|
| 55 | -{ |
|
| 54 | +interface FileInterface extends FilesystemInterface { |
|
| 56 | 55 | /** |
| 57 | 56 | * Create new file |
| 58 | 57 | * @param string $path |
@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | * Class AbstractLocal |
| 58 | 58 | * @package Platine\Filesystem\Adapter\Local |
| 59 | 59 | */ |
| 60 | -abstract class AbstractLocal implements FilesystemInterface |
|
| 61 | -{ |
|
| 60 | +abstract class AbstractLocal implements FilesystemInterface { |
|
| 62 | 61 | /** |
| 63 | 62 | * The adapter instance |
| 64 | 63 | * @var AdapterInterface |
@@ -82,8 +81,7 @@ discard block |
||
| 82 | 81 | * @param string $path |
| 83 | 82 | * @param AdapterInterface $adapter |
| 84 | 83 | */ |
| 85 | - public function __construct(string $path, AdapterInterface $adapter) |
|
| 86 | - { |
|
| 84 | + public function __construct(string $path, AdapterInterface $adapter) { |
|
| 87 | 85 | $this->adapter = $adapter; |
| 88 | 86 | $this->setPath($path); |
| 89 | 87 | } |
@@ -133,8 +131,7 @@ discard block |
||
| 133 | 131 | /** |
| 134 | 132 | * {@inheritdoc} |
| 135 | 133 | */ |
| 136 | - public function moveTo($directory) |
|
| 137 | - { |
|
| 134 | + public function moveTo($directory) { |
|
| 138 | 135 | $dest = $this->copyTo($directory); |
| 139 | 136 | $dest->touch($this->getMtime()); |
| 140 | 137 | $this->delete(); |
@@ -145,8 +142,7 @@ discard block |
||
| 145 | 142 | /** |
| 146 | 143 | * {@inheritdoc} |
| 147 | 144 | */ |
| 148 | - public function chmod(int $mode) |
|
| 149 | - { |
|
| 145 | + public function chmod(int $mode) { |
|
| 150 | 146 | chmod($this->path, $mode); |
| 151 | 147 | |
| 152 | 148 | return $this; |
@@ -244,8 +240,7 @@ discard block |
||
| 244 | 240 | /** |
| 245 | 241 | * {@inheritdoc} |
| 246 | 242 | */ |
| 247 | - public function rename(string $newPath) |
|
| 248 | - { |
|
| 243 | + public function rename(string $newPath) { |
|
| 249 | 244 | $normalizedNewPath = rtrim(Path::normalizePathDS($newPath), '\\/'); |
| 250 | 245 | if (strpos($normalizedNewPath, DIRECTORY_SEPARATOR) === false) { |
| 251 | 246 | $normalizedNewPath = dirname($this->originalPath) |
@@ -264,8 +259,7 @@ discard block |
||
| 264 | 259 | /** |
| 265 | 260 | * {@inheritdoc} |
| 266 | 261 | */ |
| 267 | - public function touch(int $time) |
|
| 268 | - { |
|
| 262 | + public function touch(int $time) { |
|
| 269 | 263 | touch($this->path, $time); |
| 270 | 264 | |
| 271 | 265 | return $this; |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | class File extends AbstractLocal implements FileInterface |
| 58 | 58 | { |
| 59 | 59 | /** |
| 60 | - * {@inheritdoc} |
|
| 61 | - */ |
|
| 60 | + * {@inheritdoc} |
|
| 61 | + */ |
|
| 62 | 62 | public function append(string $content): self |
| 63 | 63 | { |
| 64 | 64 | file_put_contents($this->path, $content, FILE_APPEND); |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | - * {@inheritdoc} |
|
| 71 | - */ |
|
| 70 | + * {@inheritdoc} |
|
| 71 | + */ |
|
| 72 | 72 | public function copyTo($directory, int $mode = 0775) |
| 73 | 73 | { |
| 74 | 74 | if (is_string($directory)) { |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * {@inheritdoc} |
|
| 87 | - */ |
|
| 86 | + * {@inheritdoc} |
|
| 87 | + */ |
|
| 88 | 88 | public function create(string $path, string $content = '', int $mode = 0775) |
| 89 | 89 | { |
| 90 | 90 | $file = $this->adapter->file($path)->write($content); |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | - * {@inheritdoc} |
|
| 98 | - */ |
|
| 97 | + * {@inheritdoc} |
|
| 98 | + */ |
|
| 99 | 99 | public function delete(): self |
| 100 | 100 | { |
| 101 | 101 | unlink($this->path); |
@@ -104,16 +104,16 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | - * {@inheritdoc} |
|
| 108 | - */ |
|
| 107 | + * {@inheritdoc} |
|
| 108 | + */ |
|
| 109 | 109 | public function getExtension(): string |
| 110 | 110 | { |
| 111 | 111 | return pathinfo($this->path, PATHINFO_EXTENSION); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | - * {@inheritdoc} |
|
| 116 | - */ |
|
| 115 | + * {@inheritdoc} |
|
| 116 | + */ |
|
| 117 | 117 | public function getMime(): string |
| 118 | 118 | { |
| 119 | 119 | $mime = mime_content_type($this->path); |
@@ -125,24 +125,24 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * {@inheritdoc} |
|
| 129 | - */ |
|
| 128 | + * {@inheritdoc} |
|
| 129 | + */ |
|
| 130 | 130 | public function getType(): string |
| 131 | 131 | { |
| 132 | 132 | return 'file'; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * {@inheritdoc} |
|
| 137 | - */ |
|
| 136 | + * {@inheritdoc} |
|
| 137 | + */ |
|
| 138 | 138 | public function read(): string |
| 139 | 139 | { |
| 140 | 140 | return (string) file_get_contents($this->path); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | - * {@inheritdoc} |
|
| 145 | - */ |
|
| 144 | + * {@inheritdoc} |
|
| 145 | + */ |
|
| 146 | 146 | public function write(string $content): self |
| 147 | 147 | { |
| 148 | 148 | file_put_contents($this->path, $content); |
@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | * Class File |
| 55 | 55 | * @package Platine\Filesystem\Adapter\Local |
| 56 | 56 | */ |
| 57 | -class File extends AbstractLocal implements FileInterface |
|
| 58 | -{ |
|
| 57 | +class File extends AbstractLocal implements FileInterface { |
|
| 59 | 58 | /** |
| 60 | 59 | * {@inheritdoc} |
| 61 | 60 | */ |
@@ -69,8 +68,7 @@ discard block |
||
| 69 | 68 | /** |
| 70 | 69 | * {@inheritdoc} |
| 71 | 70 | */ |
| 72 | - public function copyTo($directory, int $mode = 0775) |
|
| 73 | - { |
|
| 71 | + public function copyTo($directory, int $mode = 0775) { |
|
| 74 | 72 | if (is_string($directory)) { |
| 75 | 73 | $directory = $this->adapter->directory($directory); |
| 76 | 74 | } |
@@ -85,8 +83,7 @@ discard block |
||
| 85 | 83 | /** |
| 86 | 84 | * {@inheritdoc} |
| 87 | 85 | */ |
| 88 | - public function create(string $path, string $content = '', int $mode = 0775) |
|
| 89 | - { |
|
| 86 | + public function create(string $path, string $content = '', int $mode = 0775) { |
|
| 90 | 87 | $file = $this->adapter->file($path)->write($content); |
| 91 | 88 | $file->chmod($mode); |
| 92 | 89 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | class Directory extends AbstractLocal implements DirectoryInterface |
| 60 | 60 | { |
| 61 | 61 | /** |
| 62 | - * {@inheritdoc} |
|
| 63 | - */ |
|
| 62 | + * {@inheritdoc} |
|
| 63 | + */ |
|
| 64 | 64 | public function copyTo($directory, int $mode = 0775) |
| 65 | 65 | { |
| 66 | 66 | if (!$this->exists()) { |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | - * {@inheritdoc} |
|
| 98 | - */ |
|
| 97 | + * {@inheritdoc} |
|
| 98 | + */ |
|
| 99 | 99 | public function create(string $name, int $mode = 0775, bool $recursive = false) |
| 100 | 100 | { |
| 101 | 101 | if (!file_exists($this->path . DIRECTORY_SEPARATOR . $name)) { |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | - * {@inheritdoc} |
|
| 114 | - */ |
|
| 113 | + * {@inheritdoc} |
|
| 114 | + */ |
|
| 115 | 115 | public function createFile( |
| 116 | 116 | string $name, |
| 117 | 117 | string $content = '', |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | - * {@inheritdoc} |
|
| 130 | - */ |
|
| 129 | + * {@inheritdoc} |
|
| 130 | + */ |
|
| 131 | 131 | public function delete(): self |
| 132 | 132 | { |
| 133 | 133 | if (!$this->exists()) { |
@@ -143,16 +143,16 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | - * {@inheritdoc} |
|
| 147 | - */ |
|
| 146 | + * {@inheritdoc} |
|
| 147 | + */ |
|
| 148 | 148 | public function getType(): string |
| 149 | 149 | { |
| 150 | 150 | return 'dir'; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | - * {@inheritdoc} |
|
| 155 | - */ |
|
| 154 | + * {@inheritdoc} |
|
| 155 | + */ |
|
| 156 | 156 | public function read(int $type = self::ALL): array |
| 157 | 157 | { |
| 158 | 158 | $files = [ |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | - * {@inheritdoc} |
|
| 199 | - */ |
|
| 198 | + * {@inheritdoc} |
|
| 199 | + */ |
|
| 200 | 200 | public function scan(): array |
| 201 | 201 | { |
| 202 | 202 | $list = []; |
@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | * Class LocalAdpater |
| 58 | 58 | * @package Platine\Filesystem\Adapter\Local |
| 59 | 59 | */ |
| 60 | -class LocalAdapter implements AdapterInterface |
|
| 61 | -{ |
|
| 60 | +class LocalAdapter implements AdapterInterface { |
|
| 62 | 61 | /** |
| 63 | 62 | * The root directory |
| 64 | 63 | * @var string |
@@ -69,8 +68,7 @@ discard block |
||
| 69 | 68 | * Create new instance |
| 70 | 69 | * @param string $root |
| 71 | 70 | */ |
| 72 | - public function __construct(string $root = '') |
|
| 73 | - { |
|
| 71 | + public function __construct(string $root = '') { |
|
| 74 | 72 | if ($root !== '') { |
| 75 | 73 | $root = Path::normalizePathDS($root, true); |
| 76 | 74 | |
@@ -105,8 +103,7 @@ discard block |
||
| 105 | 103 | /** |
| 106 | 104 | * {@inheritdoc} |
| 107 | 105 | */ |
| 108 | - public function get(string $path) |
|
| 109 | - { |
|
| 106 | + public function get(string $path) { |
|
| 110 | 107 | $absolutePath = $this->getAbsolutePath($path); |
| 111 | 108 | |
| 112 | 109 | if (is_file($absolutePath)) { |
@@ -54,8 +54,7 @@ |
||
| 54 | 54 | * Class AdapterInterface |
| 55 | 55 | * @package Platine\Filesystem\Adapter |
| 56 | 56 | */ |
| 57 | -interface AdapterInterface |
|
| 58 | -{ |
|
| 57 | +interface AdapterInterface { |
|
| 59 | 58 | /** |
| 60 | 59 | * Return the instance of file or directory |
| 61 | 60 | * @param string $path |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | * Class DirectoryInterface |
| 52 | 52 | * @package Platine\Filesystem |
| 53 | 53 | */ |
| 54 | -interface DirectoryInterface extends FilesystemInterface |
|
| 55 | -{ |
|
| 54 | +interface DirectoryInterface extends FilesystemInterface { |
|
| 56 | 55 | /** |
| 57 | 56 | * Filter list for directory read |
| 58 | 57 | */ |