@@ -56,12 +56,12 @@ |
||
56 | 56 | */ |
57 | 57 | public static function value2string($value) : string |
58 | 58 | { |
59 | - if($value === true) |
|
59 | + if ($value === true) |
|
60 | 60 | { |
61 | 61 | return 'true'; |
62 | 62 | } |
63 | 63 | |
64 | - if($value === false) |
|
64 | + if ($value === false) |
|
65 | 65 | { |
66 | 66 | return 'false'; |
67 | 67 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * @param bool $enabled |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function prop(string $name, bool $enabled=true) : self; |
|
56 | + public function prop(string $name, bool $enabled = true) : self; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @param string $name |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param mixed $default The default value to return if the option does not exist. |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - public function getOption(string $name, $default=null); |
|
48 | + public function getOption(string $name, $default = null); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @param string $name |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getArrayOption(string $name) : array; |
55 | 55 | |
56 | - public function getIntOption(string $name, int $default=0) : int; |
|
56 | + public function getIntOption(string $name, int $default = 0) : int; |
|
57 | 57 | |
58 | - public function getBoolOption(string $name, bool $default=false) : bool; |
|
58 | + public function getBoolOption(string $name, bool $default = false) : bool; |
|
59 | 59 | |
60 | - public function getStringOption(string $name, string $default='') : string; |
|
60 | + public function getStringOption(string $name, string $default = '') : string; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Sets a collection of options at once, from an |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public function addLimitParam(string $name) : Request_URLComparer |
83 | 83 | { |
84 | - if(!in_array($name, $this->limitParams, true)) |
|
84 | + if (!in_array($name, $this->limitParams, true)) |
|
85 | 85 | { |
86 | 86 | $this->limitParams[] = $name; |
87 | 87 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function addLimitParams(array $names) : Request_URLComparer |
97 | 97 | { |
98 | - foreach($names as $name) |
|
98 | + foreach ($names as $name) |
|
99 | 99 | { |
100 | 100 | $this->addLimitParam($name); |
101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return $this; |
104 | 104 | } |
105 | 105 | |
106 | - public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer |
|
106 | + public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer |
|
107 | 107 | { |
108 | 108 | $this->ignoreFragment = $ignore; |
109 | 109 | return $this; |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | 'query' |
127 | 127 | ); |
128 | 128 | |
129 | - if(!$this->ignoreFragment) { |
|
129 | + if (!$this->ignoreFragment) { |
|
130 | 130 | $keys[] = 'fragment'; |
131 | 131 | } |
132 | 132 | |
133 | - foreach($keys as $key) |
|
133 | + foreach ($keys as $key) |
|
134 | 134 | { |
135 | - if(!$this->compareKey($key)) { |
|
135 | + if (!$this->compareKey($key)) { |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $filter = 'filter_'.$key; |
149 | 149 | |
150 | - if(method_exists($this, $filter)) |
|
150 | + if (method_exists($this, $filter)) |
|
151 | 151 | { |
152 | 152 | $sVal = $this->$filter($sVal); |
153 | 153 | $tVal = $this->$filter($tVal); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | protected function filter_path(string $path) : string |
160 | 160 | { |
161 | 161 | // fix double slashes in URLs |
162 | - while(strpos($path, '//') !== false) |
|
162 | + while (strpos($path, '//') !== false) |
|
163 | 163 | { |
164 | 164 | $path = str_replace('//', '/', $path); |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | protected function filter_query(string $query) : string |
171 | 171 | { |
172 | - if(empty($query)) { |
|
172 | + if (empty($query)) { |
|
173 | 173 | return ''; |
174 | 174 | } |
175 | 175 | |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | */ |
189 | 189 | protected function limitParams(array $params) : array |
190 | 190 | { |
191 | - if(empty($this->limitParams)) { |
|
191 | + if (empty($this->limitParams)) { |
|
192 | 192 | return $params; |
193 | 193 | } |
194 | 194 | |
195 | 195 | $keep = array(); |
196 | 196 | |
197 | - foreach($this->limitParams as $name) |
|
197 | + foreach ($this->limitParams as $name) |
|
198 | 198 | { |
199 | - if(isset($params[$name])) { |
|
199 | + if (isset($params[$name])) { |
|
200 | 200 | $keep[$name] = $params[$name]; |
201 | 201 | } |
202 | 202 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size. |
52 | 52 | $result = (float)preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size. |
53 | 53 | |
54 | - if($unit) |
|
54 | + if ($unit) |
|
55 | 55 | { |
56 | 56 | // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by. |
57 | 57 | return (int)round($result * (1024 ** stripos('bkmgtpezy', $unit[0]))); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param int $depth The folder depth to reduce the path to |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public static function relativizeByDepth(string $path, int $depth=2) : string |
|
21 | + public static function relativizeByDepth(string $path, int $depth = 2) : string |
|
22 | 22 | { |
23 | 23 | $path = FileHelper::normalizePath($path); |
24 | 24 | |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | $tokens = array_filter($tokens); // remove empty entries (trailing slash for example) |
27 | 27 | $tokens = array_values($tokens); // re-index keys |
28 | 28 | |
29 | - if(empty($tokens)) { |
|
29 | + if (empty($tokens)) { |
|
30 | 30 | return ''; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // remove the drive if present |
34 | - if(strpos($tokens[0], ':') !== false) { |
|
34 | + if (strpos($tokens[0], ':') !== false) { |
|
35 | 35 | array_shift($tokens); |
36 | 36 | } |
37 | 37 | |
38 | 38 | // path was only the drive |
39 | - if(count($tokens) === 0) { |
|
39 | + if (count($tokens) === 0) { |
|
40 | 40 | return ''; |
41 | 41 | } |
42 | 42 | |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | |
46 | 46 | // reduce the path to the specified depth |
47 | 47 | $length = count($tokens); |
48 | - if($length > $depth) { |
|
49 | - $tokens = array_slice($tokens, $length-$depth); |
|
48 | + if ($length > $depth) { |
|
49 | + $tokens = array_slice($tokens, $length - $depth); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // append the last element again |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @see \AppUtils\FileHelper\FileFinder |
8 | 8 | */ |
9 | 9 | |
10 | -declare(strict_types = 1); |
|
10 | +declare(strict_types=1); |
|
11 | 11 | |
12 | 12 | namespace AppUtils\FileHelper; |
13 | 13 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param bool $enabled |
91 | 91 | * @return FileFinder |
92 | 92 | */ |
93 | - public function makeRecursive(bool $enabled=true) : FileFinder |
|
93 | + public function makeRecursive(bool $enabled = true) : FileFinder |
|
94 | 94 | { |
95 | 95 | return $this->setOption('recursive', $enabled); |
96 | 96 | } |
@@ -295,22 +295,22 @@ discard block |
||
295 | 295 | return $this->getAll(); |
296 | 296 | } |
297 | 297 | |
298 | - protected function find(string $path, bool $isRoot=false) : void |
|
298 | + protected function find(string $path, bool $isRoot = false) : void |
|
299 | 299 | { |
300 | - if($isRoot) { |
|
300 | + if ($isRoot) { |
|
301 | 301 | $this->found = array(); |
302 | 302 | } |
303 | 303 | |
304 | 304 | $recursive = $this->getBoolOption('recursive'); |
305 | 305 | |
306 | 306 | $d = new DirectoryIterator($path); |
307 | - foreach($d as $item) |
|
307 | + foreach ($d as $item) |
|
308 | 308 | { |
309 | 309 | $pathname = $item->getPathname(); |
310 | 310 | |
311 | - if($item->isDir()) |
|
311 | + if ($item->isDir()) |
|
312 | 312 | { |
313 | - if($recursive && !$item->isDot()) { |
|
313 | + if ($recursive && !$item->isDot()) { |
|
314 | 314 | $this->find($pathname); |
315 | 315 | } |
316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | $file = $this->filterFile($pathname); |
321 | 321 | |
322 | - if($file !== null) |
|
322 | + if ($file !== null) |
|
323 | 323 | { |
324 | 324 | $this->found[] = $file; |
325 | 325 | } |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | |
333 | 333 | $extension = FileHelper::getExtension($path); |
334 | 334 | |
335 | - if(!$this->filterExclusion($extension)) { |
|
335 | + if (!$this->filterExclusion($extension)) { |
|
336 | 336 | return null; |
337 | 337 | } |
338 | 338 | |
339 | 339 | $path = $this->filterPath($path); |
340 | 340 | |
341 | - if($this->getOption('strip-extensions') === true) |
|
341 | + if ($this->getOption('strip-extensions') === true) |
|
342 | 342 | { |
343 | 343 | $path = str_replace('.'.$extension, '', $path); |
344 | 344 | } |
345 | 345 | |
346 | - if($path === '') { |
|
346 | + if ($path === '') { |
|
347 | 347 | return null; |
348 | 348 | } |
349 | 349 | |
350 | 350 | $replace = $this->getOption('slash-replacement'); |
351 | - if(!empty($replace)) { |
|
351 | + if (!empty($replace)) { |
|
352 | 352 | $path = str_replace('/', $replace, $path); |
353 | 353 | } |
354 | 354 | |
@@ -367,13 +367,13 @@ discard block |
||
367 | 367 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
368 | 368 | $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS); |
369 | 369 | |
370 | - if(!empty($include)) |
|
370 | + if (!empty($include)) |
|
371 | 371 | { |
372 | - if(!in_array($extension, $include, true)) { |
|
372 | + if (!in_array($extension, $include, true)) { |
|
373 | 373 | return false; |
374 | 374 | } |
375 | 375 | } |
376 | - else if(!empty($exclude) && in_array($extension, $exclude, true)) |
|
376 | + else if (!empty($exclude) && in_array($extension, $exclude, true)) |
|
377 | 377 | { |
378 | 378 | return false; |
379 | 379 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | protected function filterPath(string $path) : string |
391 | 391 | { |
392 | - switch($this->getStringOption(self::OPTION_PATHMODE)) |
|
392 | + switch ($this->getStringOption(self::OPTION_PATHMODE)) |
|
393 | 393 | { |
394 | 394 | case self::PATH_MODE_STRIP: |
395 | 395 | return basename($path); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return $this |
125 | 125 | * @throws Request_Exception |
126 | 126 | */ |
127 | - public function setCallback(callable $callback, array $args=array()) : self |
|
127 | + public function setCallback(callable $callback, array $args = array()) : self |
|
128 | 128 | { |
129 | 129 | return $this->setValidation( |
130 | 130 | self::VALIDATION_TYPE_CALLBACK, |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | // first off, apply filtering |
150 | 150 | $value = $this->filter($value); |
151 | 151 | |
152 | - if($this->valueType === self::VALUE_TYPE_LIST) |
|
152 | + if ($this->valueType === self::VALUE_TYPE_LIST) |
|
153 | 153 | { |
154 | - if(!is_array($value)) |
|
154 | + if (!is_array($value)) |
|
155 | 155 | { |
156 | 156 | $value = explode(',', $value); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $keep = array(); |
160 | 160 | |
161 | - foreach($value as $subval) |
|
161 | + foreach ($value as $subval) |
|
162 | 162 | { |
163 | 163 | $subval = $this->filter($subval); |
164 | 164 | |
165 | 165 | $subval = $this->applyValidations($subval, true); |
166 | 166 | |
167 | - if($subval !== null) { |
|
167 | + if ($subval !== null) { |
|
168 | 168 | $keep[] = $subval; |
169 | 169 | } |
170 | 170 | } |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param mixed $value |
184 | 184 | * @return mixed |
185 | 185 | */ |
186 | - protected function applyValidations($value, bool $subval=false) |
|
186 | + protected function applyValidations($value, bool $subval = false) |
|
187 | 187 | { |
188 | 188 | // go through all enqueued validations in turn, each time |
189 | 189 | // replacing the value with the adjusted, validated value. |
190 | - foreach($this->validations as $validateDef) |
|
190 | + foreach ($this->validations as $validateDef) |
|
191 | 191 | { |
192 | 192 | $value = $this->validateType($value, $validateDef['type'], $validateDef['params'], $subval); |
193 | 193 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | $class = Request_Param_Validator::class.'_'.ucfirst($type); |
212 | 212 | |
213 | - if(!class_exists($class)) |
|
213 | + if (!class_exists($class)) |
|
214 | 214 | { |
215 | 215 | throw new Request_Exception( |
216 | 216 | 'Unknown validation type.', |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | { |
362 | 362 | $args = func_get_args(); // cannot be used as function parameter in some PHP versions |
363 | 363 | |
364 | - if(is_array($args[0])) |
|
364 | + if (is_array($args[0])) |
|
365 | 365 | { |
366 | 366 | $args = $args[0]; |
367 | 367 | } |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | * @param mixed $default |
512 | 512 | * @return mixed |
513 | 513 | */ |
514 | - public function get($default=null) |
|
514 | + public function get($default = null) |
|
515 | 515 | { |
516 | 516 | $value = $this->request->getParam($this->paramName); |
517 | - if($value !== null && $value !== '') { |
|
517 | + if ($value !== null && $value !== '') { |
|
518 | 518 | return $value; |
519 | 519 | } |
520 | 520 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | { |
539 | 539 | foreach ($this->filters as $filter) |
540 | 540 | { |
541 | - $method = 'applyFilter_' . $filter['type']; |
|
541 | + $method = 'applyFilter_'.$filter['type']; |
|
542 | 542 | $value = $this->$method($value, $filter['params']); |
543 | 543 | } |
544 | 544 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | $filter = new $class($this); |
559 | 559 | |
560 | - if($filter instanceof Request_Param_Filter) |
|
560 | + if ($filter instanceof Request_Param_Filter) |
|
561 | 561 | { |
562 | 562 | $filter->setOptions($config['params']); |
563 | 563 | return $filter->filter($value); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
717 | 717 | * @return $this |
718 | 718 | */ |
719 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : self |
|
719 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : self |
|
720 | 720 | { |
721 | 721 | $this->setArray(); |
722 | 722 | |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * @return $this |
736 | 736 | * @throws Request_Exception |
737 | 737 | */ |
738 | - protected function addClassFilter(string $name, array $params=array()) : self |
|
738 | + protected function addClassFilter(string $name, array $params = array()) : self |
|
739 | 739 | { |
740 | 740 | return $this->addFilter( |
741 | 741 | self::FILTER_TYPE_CLASS, |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | $info = FileHelper::getFolderInfo($rootFolder); |
24 | 24 | |
25 | - if(!$info->exists()) |
|
25 | + if (!$info->exists()) |
|
26 | 26 | { |
27 | 27 | return true; |
28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | foreach ($d as $item) |
33 | 33 | { |
34 | - if(self::processDeleteItem($item) === false) |
|
34 | + if (self::processDeleteItem($item) === false) |
|
35 | 35 | { |
36 | 36 | return false; |
37 | 37 | } |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | { |
101 | 101 | $target = FileHelper::createFolder($target); |
102 | 102 | |
103 | - $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator(); |
|
103 | + $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator(); |
|
104 | 104 | |
105 | 105 | foreach ($d as $item) |
106 | 106 | { |
107 | - if($item->isDot()) |
|
107 | + if ($item->isDot()) |
|
108 | 108 | { |
109 | 109 | continue; |
110 | 110 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($item->isFolder()) |
127 | 127 | { |
128 | - self::copy($item, $target . '/' . $item->getName()); |
|
128 | + self::copy($item, $target.'/'.$item->getName()); |
|
129 | 129 | } |
130 | - else if($item->isFile()) |
|
130 | + else if ($item->isFile()) |
|
131 | 131 | { |
132 | 132 | $item |
133 | 133 | ->requireIsFile() |