@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @param array<string,mixed> $data |
| 39 | 39 | */ |
| 40 | - public function __construct(array $data=array()) |
|
| 40 | + public function __construct(array $data = array()) |
|
| 41 | 41 | { |
| 42 | 42 | $this->data = $data; |
| 43 | 43 | } |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * @param ArrayDataCollection|array<string,mixed>|NULL $data |
| 47 | 47 | * @return ArrayDataCollection |
| 48 | 48 | */ |
| 49 | - public static function create($data=array()) : ArrayDataCollection |
|
| 49 | + public static function create($data = array()) : ArrayDataCollection |
|
| 50 | 50 | { |
| 51 | - if($data instanceof self) { |
|
| 51 | + if ($data instanceof self) { |
|
| 52 | 52 | return $data; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function setKeys(array $data) : self |
| 71 | 71 | { |
| 72 | - foreach($data as $key => $value) |
|
| 72 | + foreach ($data as $key => $value) |
|
| 73 | 73 | { |
| 74 | 74 | $this->setKey($key, $value); |
| 75 | 75 | } |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $value = $this->getKey($name); |
| 139 | 139 | |
| 140 | - if(is_string($value)) { |
|
| 140 | + if (is_string($value)) { |
|
| 141 | 141 | return $value; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if(is_numeric($value)) { |
|
| 144 | + if (is_numeric($value)) { |
|
| 145 | 145 | return (string)$value; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $value = $this->getKey($name); |
| 162 | 162 | |
| 163 | - if(is_numeric($value)) { |
|
| 163 | + if (is_numeric($value)) { |
|
| 164 | 164 | return (int)$value; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $value = $this->getString($name); |
| 184 | 184 | |
| 185 | - if(empty($value)) { |
|
| 185 | + if (empty($value)) { |
|
| 186 | 186 | return array(); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | $value = json_decode($value, true, 512, JSON_THROW_ON_ERROR); |
| 192 | 192 | |
| 193 | - if(is_array($value)) { |
|
| 193 | + if (is_array($value)) { |
|
| 194 | 194 | return $value; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | $value = $this->getKey($name); |
| 222 | 222 | |
| 223 | - if(is_array($value)) { |
|
| 223 | + if (is_array($value)) { |
|
| 224 | 224 | return $value; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | { |
| 232 | 232 | $value = $this->getKey($name); |
| 233 | 233 | |
| 234 | - if(is_string($value)) { |
|
| 234 | + if (is_string($value)) { |
|
| 235 | 235 | $value = strtolower($value); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | { |
| 250 | 250 | $value = $this->getKey($name); |
| 251 | 251 | |
| 252 | - if(is_numeric($value)) { |
|
| 252 | + if (is_numeric($value)) { |
|
| 253 | 253 | return (float)$value; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $pathString = AbstractPathInfo::type2string($path); |
| 67 | 67 | $endingChar = $pathString[strlen($pathString) - 1]; |
| 68 | 68 | |
| 69 | - if(empty($path)) { |
|
| 69 | + if (empty($path)) { |
|
| 70 | 70 | throw new FileHelper_Exception( |
| 71 | 71 | 'Invalid', |
| 72 | 72 | '', |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\') |
|
| 77 | + if ($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\') |
|
| 78 | 78 | { |
| 79 | 79 | throw new FileHelper_Exception( |
| 80 | 80 | 'Cannot use a folder as a file', |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | $key = $pathString.';'.static::class; |
| 90 | 90 | |
| 91 | - if(!isset(self::$infoCache[$key])) |
|
| 91 | + if (!isset(self::$infoCache[$key])) |
|
| 92 | 92 | { |
| 93 | 93 | $class = static::class; |
| 94 | 94 | $instance = new $class($pathString); |
| 95 | 95 | |
| 96 | - if(!$instance instanceof self) { |
|
| 96 | + if (!$instance instanceof self) { |
|
| 97 | 97 | throw new FileHelper_Exception( |
| 98 | 98 | 'Invalid class created', |
| 99 | 99 | sprintf( |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | $path = trim($path); |
| 130 | 130 | |
| 131 | - if(empty($path) || FolderInfo::is_dir($path)) |
|
| 131 | + if (empty($path) || FolderInfo::is_dir($path)) |
|
| 132 | 132 | { |
| 133 | 133 | return false; |
| 134 | 134 | } |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | return is_file($path) || pathinfo($path, PATHINFO_EXTENSION) !== ''; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function removeExtension(bool $keepPath=false) : string |
|
| 139 | + public function removeExtension(bool $keepPath = false) : string |
|
| 140 | 140 | { |
| 141 | - if(!$keepPath) |
|
| 141 | + if (!$keepPath) |
|
| 142 | 142 | { |
| 143 | 143 | return (string)pathinfo($this->getName(), PATHINFO_FILENAME); |
| 144 | 144 | } |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | return $this->removeExtension(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public function getExtension(bool $lowercase=true) : string |
|
| 166 | + public function getExtension(bool $lowercase = true) : string |
|
| 167 | 167 | { |
| 168 | 168 | $ext = (string)pathinfo($this->path, PATHINFO_EXTENSION); |
| 169 | 169 | |
| 170 | - if($lowercase) |
|
| 170 | + if ($lowercase) |
|
| 171 | 171 | { |
| 172 | 172 | $ext = mb_strtolower($ext); |
| 173 | 173 | } |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function delete() : FileInfo |
| 190 | 190 | { |
| 191 | - if(!$this->exists()) |
|
| 191 | + if (!$this->exists()) |
|
| 192 | 192 | { |
| 193 | 193 | return $this; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if(unlink($this->path)) |
|
| 196 | + if (unlink($this->path)) |
|
| 197 | 197 | { |
| 198 | 198 | return $this; |
| 199 | 199 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | $target = $this->checkCopyPrerequisites($targetPath); |
| 222 | 222 | |
| 223 | - if(copy($this->path, (string)$target)) |
|
| 223 | + if (copy($this->path, (string)$target)) |
|
| 224 | 224 | { |
| 225 | 225 | return $target; |
| 226 | 226 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $target = FileHelper::getPathInfo($targetPath); |
| 258 | 258 | |
| 259 | 259 | // It's a file? Then we can use it as-is. |
| 260 | - if($target instanceof self) { |
|
| 260 | + if ($target instanceof self) { |
|
| 261 | 261 | return $target |
| 262 | 262 | ->requireIsFile() |
| 263 | 263 | ->createFolder(); |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | // but is not a folder: very likely a file without extension. |
| 268 | 268 | // In this case we create an empty file to be able to return |
| 269 | 269 | // a FileInfo instance. |
| 270 | - if($target instanceof IndeterminatePath) |
|
| 270 | + if ($target instanceof IndeterminatePath) |
|
| 271 | 271 | { |
| 272 | 272 | return $target->convertToFile(); |
| 273 | 273 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public function getLineReader() : LineReader |
| 298 | 298 | { |
| 299 | - if($this->lineReader === null) |
|
| 299 | + if ($this->lineReader === null) |
|
| 300 | 300 | { |
| 301 | 301 | $this->lineReader = new LineReader($this); |
| 302 | 302 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | $result = file_get_contents($this->getPath()); |
| 317 | 317 | |
| 318 | - if($result !== false) { |
|
| 318 | + if ($result !== false) { |
|
| 319 | 319 | return $result; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public function putContents(string $content) : FileInfo |
| 339 | 339 | { |
| 340 | - if($this->exists()) |
|
| 340 | + if ($this->exists()) |
|
| 341 | 341 | { |
| 342 | 342 | $this->requireWritable(); |
| 343 | 343 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | ->requireWritable(); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if(file_put_contents($this->path, $content) !== false) |
|
| 351 | + if (file_put_contents($this->path, $content) !== false) |
|
| 352 | 352 | { |
| 353 | 353 | return $this; |
| 354 | 354 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | private function createFolder() : FileInfo |
| 380 | 380 | { |
| 381 | - if(!$this->exists()) |
|
| 381 | + if (!$this->exists()) |
|
| 382 | 382 | { |
| 383 | 383 | FolderInfo::factory($this->getFolderPath()) |
| 384 | 384 | ->create() |