@@ -18,23 +18,23 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public function __construct(array $size) |
| 20 | 20 | { |
| 21 | - if(!isset($size['width'])) { |
|
| 21 | + if (!isset($size['width'])) { |
|
| 22 | 22 | $size['width'] = $size[0]; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if(!isset($size['height'])) { |
|
| 25 | + if (!isset($size['height'])) { |
|
| 26 | 26 | $size['height'] = $size[1]; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if(!isset($size[0])) { |
|
| 29 | + if (!isset($size[0])) { |
|
| 30 | 30 | $size[0] = $size['width']; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if(!isset($size[1])) { |
|
| 33 | + if (!isset($size[1])) { |
|
| 34 | 34 | $size[1] = $size['height']; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if(!isset($size['channels'])) { |
|
| 37 | + if (!isset($size['channels'])) { |
|
| 38 | 38 | $size['channels'] = 1; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function offsetGet($offset) |
| 70 | 70 | { |
| 71 | - if(isset($this->size[$offset])) { |
|
| 71 | + if (isset($this->size[$offset])) { |
|
| 72 | 72 | return $this->size[$offset]; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function offsetSet($offset, $value) |
| 79 | 79 | { |
| 80 | - if(is_null($offset)) { |
|
| 80 | + if (is_null($offset)) { |
|
| 81 | 81 | $this->size[] = $value; |
| 82 | 82 | } else { |
| 83 | 83 | $this->size[$offset] = $value; |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | <br> |
| 43 | 43 | <?php |
| 44 | 44 | |
| 45 | - foreach($urls as $url) |
|
| 45 | + foreach ($urls as $url) |
|
| 46 | 46 | { |
| 47 | 47 | $info = parseURL($url); |
| 48 | 48 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | $autoload = realpath($root.'/../vendor/autoload.php'); |
| 13 | 13 | |
| 14 | 14 | // we need the autoloader to be present |
| 15 | - if($autoload === false) |
|
| 15 | + if ($autoload === false) |
|
| 16 | 16 | { |
| 17 | 17 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
| 18 | 18 | } |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | * @param array $args |
| 124 | 124 | * @return Request_Param |
| 125 | 125 | */ |
| 126 | - public function setCallback($callback, $args=array()) |
|
| 126 | + public function setCallback($callback, $args = array()) |
|
| 127 | 127 | { |
| 128 | - if(!is_callable($callback)) { |
|
| 128 | + if (!is_callable($callback)) { |
|
| 129 | 129 | throw new Request_Exception( |
| 130 | 130 | 'Not a valid callback', |
| 131 | 131 | 'The specified callback is not a valid callable entity.', |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | array_unshift($args, $value); |
| 149 | 149 | |
| 150 | 150 | $result = call_user_func_array($this->validationParams['callback'], $args); |
| 151 | - if($result !== false) { |
|
| 151 | + if ($result !== false) { |
|
| 152 | 152 | return $value; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -175,13 +175,13 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | // go through all enqueued validations in turn, each time |
| 177 | 177 | // replacing the value with the adjusted, validated value. |
| 178 | - foreach($this->validations as $validateDef) |
|
| 178 | + foreach ($this->validations as $validateDef) |
|
| 179 | 179 | { |
| 180 | 180 | $this->validationType = $validateDef['type']; |
| 181 | 181 | $this->validationParams = $validateDef['params']; |
| 182 | 182 | |
| 183 | 183 | // and now, see if we have to validate the value as well |
| 184 | - $method = 'validate_' . $this->validationType; |
|
| 184 | + $method = 'validate_'.$this->validationType; |
|
| 185 | 185 | if (!method_exists($this, $method)) { |
| 186 | 186 | throw new Request_Exception( |
| 187 | 187 | 'Unknown validation type.', |
@@ -195,19 +195,19 @@ discard block |
||
| 195 | 195 | ); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if($this->valueType === self::VALUE_TYPE_ID_LIST) |
|
| 198 | + if ($this->valueType === self::VALUE_TYPE_ID_LIST) |
|
| 199 | 199 | { |
| 200 | - if(!is_array($value)) { |
|
| 200 | + if (!is_array($value)) { |
|
| 201 | 201 | $value = explode(',', $value); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | $keep = array(); |
| 205 | - foreach($value as $subval) |
|
| 205 | + foreach ($value as $subval) |
|
| 206 | 206 | { |
| 207 | 207 | $subval = trim($subval); |
| 208 | 208 | $subval = $this->$method($subval); |
| 209 | 209 | |
| 210 | - if($subval !== null) { |
|
| 210 | + if ($subval !== null) { |
|
| 211 | 211 | $keep[] = intval($subval); |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | protected function applyFilter_boolean($value) |
| 425 | 425 | { |
| 426 | - if($value == 'yes' || $value == 'true') { |
|
| 426 | + if ($value == 'yes' || $value == 'true') { |
|
| 427 | 427 | return true; |
| 428 | 428 | } |
| 429 | 429 | |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | protected function applyFilter_string($value) |
| 439 | 439 | { |
| 440 | - if(!is_scalar($value)) { |
|
| 440 | + if (!is_scalar($value)) { |
|
| 441 | 441 | return ''; |
| 442 | 442 | } |
| 443 | 443 | |
@@ -446,29 +446,29 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | protected function applyFilter_commaSeparated($value, bool $trimEntries, bool $stripEmptyEntries) |
| 448 | 448 | { |
| 449 | - if(is_array($value)) { |
|
| 449 | + if (is_array($value)) { |
|
| 450 | 450 | return $value; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if($value === '' || $value === null || !is_string($value)) { |
|
| 453 | + if ($value === '' || $value === null || !is_string($value)) { |
|
| 454 | 454 | return array(); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | $result = explode(',', $value); |
| 458 | 458 | |
| 459 | - if(!$trimEntries && !$stripEmptyEntries) { |
|
| 459 | + if (!$trimEntries && !$stripEmptyEntries) { |
|
| 460 | 460 | return $result; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | $keep = array(); |
| 464 | 464 | |
| 465 | - foreach($result as $entry) |
|
| 465 | + foreach ($result as $entry) |
|
| 466 | 466 | { |
| 467 | - if($trimEntries === true) { |
|
| 467 | + if ($trimEntries === true) { |
|
| 468 | 468 | $entry = trim($entry); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if($stripEmptyEntries === true && $entry === '') { |
|
| 471 | + if ($stripEmptyEntries === true && $entry === '') { |
|
| 472 | 472 | continue; |
| 473 | 473 | } |
| 474 | 474 | |
@@ -536,10 +536,10 @@ discard block |
||
| 536 | 536 | * @param mixed $default |
| 537 | 537 | * @return mixed |
| 538 | 538 | */ |
| 539 | - public function get($default=null) |
|
| 539 | + public function get($default = null) |
|
| 540 | 540 | { |
| 541 | 541 | $value = $this->request->getParam($this->paramName); |
| 542 | - if($value !== null && $value !== '') { |
|
| 542 | + if ($value !== null && $value !== '') { |
|
| 543 | 543 | return $value; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | protected function validate_integer($value) : ?int |
| 560 | 560 | { |
| 561 | - if(ConvertHelper::isInteger($value)) { |
|
| 561 | + if (ConvertHelper::isInteger($value)) { |
|
| 562 | 562 | return intval($value); |
| 563 | 563 | } |
| 564 | 564 | |
@@ -573,12 +573,12 @@ discard block |
||
| 573 | 573 | */ |
| 574 | 574 | protected function validate_url($value) : string |
| 575 | 575 | { |
| 576 | - if(!is_string($value)) { |
|
| 576 | + if (!is_string($value)) { |
|
| 577 | 577 | return ''; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | $info = parse_url($value); |
| 581 | - if(isset($info['host'])) { |
|
| 581 | + if (isset($info['host'])) { |
|
| 582 | 582 | return $value; |
| 583 | 583 | } |
| 584 | 584 | |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | */ |
| 595 | 595 | protected function validate_numeric($value) : ?float |
| 596 | 596 | { |
| 597 | - if(is_numeric($value)) { |
|
| 597 | + if (is_numeric($value)) { |
|
| 598 | 598 | return $value * 1; |
| 599 | 599 | } |
| 600 | 600 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | */ |
| 611 | 611 | protected function validate_regex($value) : ?string |
| 612 | 612 | { |
| 613 | - if(!is_scalar($value)) { |
|
| 613 | + if (!is_scalar($value)) { |
|
| 614 | 614 | return null; |
| 615 | 615 | } |
| 616 | 616 | |
@@ -618,13 +618,13 @@ discard block |
||
| 618 | 618 | // is a boolan, which is converted to an integer when |
| 619 | 619 | // converted to string, which in turn can be validated |
| 620 | 620 | // with a regex. |
| 621 | - if(is_bool($value)) { |
|
| 621 | + if (is_bool($value)) { |
|
| 622 | 622 | return null; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | $value = (string)$value; |
| 626 | 626 | |
| 627 | - if(preg_match($this->validationParams['regex'], $value)) { |
|
| 627 | + if (preg_match($this->validationParams['regex'], $value)) { |
|
| 628 | 628 | return $value; |
| 629 | 629 | } |
| 630 | 630 | |
@@ -640,11 +640,11 @@ discard block |
||
| 640 | 640 | */ |
| 641 | 641 | protected function validate_alpha($value) |
| 642 | 642 | { |
| 643 | - if(!is_scalar($value)) { |
|
| 643 | + if (!is_scalar($value)) { |
|
| 644 | 644 | return null; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - if(preg_match('/\A[a-zA-Z]+\z/', $value)) { |
|
| 647 | + if (preg_match('/\A[a-zA-Z]+\z/', $value)) { |
|
| 648 | 648 | return $value; |
| 649 | 649 | } |
| 650 | 650 | |
@@ -653,13 +653,13 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | protected function validate_valueslist($value) |
| 655 | 655 | { |
| 656 | - if(!is_array($value)) { |
|
| 656 | + if (!is_array($value)) { |
|
| 657 | 657 | return array(); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | $keep = array(); |
| 661 | - foreach($value as $item) { |
|
| 662 | - if(in_array($item, $this->validationParams)) { |
|
| 661 | + foreach ($value as $item) { |
|
| 662 | + if (in_array($item, $this->validationParams)) { |
|
| 663 | 663 | $keep[] = $item; |
| 664 | 664 | } |
| 665 | 665 | } |
@@ -716,26 +716,26 @@ discard block |
||
| 716 | 716 | */ |
| 717 | 717 | protected function validate_json($value) |
| 718 | 718 | { |
| 719 | - if(!is_string($value)) { |
|
| 719 | + if (!is_string($value)) { |
|
| 720 | 720 | return ''; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | $value = trim($value); |
| 724 | 724 | |
| 725 | - if(empty($value)) { |
|
| 725 | + if (empty($value)) { |
|
| 726 | 726 | return ''; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // strictly validate for objects? |
| 730 | - if($this->validationParams['arrays'] === false) |
|
| 730 | + if ($this->validationParams['arrays'] === false) |
|
| 731 | 731 | { |
| 732 | - if(is_object(json_decode($value))) { |
|
| 732 | + if (is_object(json_decode($value))) { |
|
| 733 | 733 | return $value; |
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | else |
| 737 | 737 | { |
| 738 | - if(is_array(json_decode($value, true))) { |
|
| 738 | + if (is_array(json_decode($value, true))) { |
|
| 739 | 739 | return $value; |
| 740 | 740 | } |
| 741 | 741 | } |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | { |
| 757 | 757 | $total = count($this->filters); |
| 758 | 758 | for ($i = 0; $i < $total; $i++) { |
| 759 | - $method = 'applyFilter_' . $this->filters[$i]['type']; |
|
| 759 | + $method = 'applyFilter_'.$this->filters[$i]['type']; |
|
| 760 | 760 | $value = $this->$method($value, $this->filters[$i]['params']); |
| 761 | 761 | } |
| 762 | 762 | |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
| 904 | 904 | * @return \AppUtils\Request_Param |
| 905 | 905 | */ |
| 906 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
|
| 906 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : Request_Param |
|
| 907 | 907 | { |
| 908 | 908 | $this->setArray(); |
| 909 | 909 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | public function isHeadersPosition($position) |
| 168 | 168 | { |
| 169 | - if($this->headersPosition === $position) { |
|
| 169 | + if ($this->headersPosition === $position) { |
|
| 170 | 170 | return true; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | self::HEADERS_TOP |
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - if(!in_array($position, $validPositions)) { |
|
| 196 | + if (!in_array($position, $validPositions)) { |
|
| 197 | 197 | throw new CSVHelper_Exception( |
| 198 | 198 | 'Invalid headers position', |
| 199 | 199 | sprintf( |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function getRow($index) |
| 251 | 251 | { |
| 252 | - if(isset($this->data[$index])) { |
|
| 252 | + if (isset($this->data[$index])) { |
|
| 253 | 253 | return $this->data[$index]; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -316,9 +316,9 @@ discard block |
||
| 316 | 316 | public function getColumn($index) |
| 317 | 317 | { |
| 318 | 318 | $data = array(); |
| 319 | - for($i=0; $i < $this->rowCount; $i++) { |
|
| 319 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
| 320 | 320 | $value = ''; |
| 321 | - if(isset($this->data[$i][$index])) { |
|
| 321 | + if (isset($this->data[$i][$index])) { |
|
| 322 | 322 | $value = $this->data[$i][$index]; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function columnExists($index) |
| 337 | 337 | { |
| 338 | - if($index < $this->columnCount) { |
|
| 338 | + if ($index < $this->columnCount) { |
|
| 339 | 339 | return true; |
| 340 | 340 | } |
| 341 | 341 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | { |
| 347 | 347 | $this->reset(); |
| 348 | 348 | |
| 349 | - if(empty(trim($this->csv))) { |
|
| 349 | + if (empty(trim($this->csv))) { |
|
| 350 | 350 | $this->addError('Tried to parse an empty CSV string.'); |
| 351 | 351 | return; |
| 352 | 352 | } |
@@ -361,12 +361,12 @@ discard block |
||
| 361 | 361 | $parser->delimiter = $this->detectSeparator(); |
| 362 | 362 | |
| 363 | 363 | $result = $parser->parse_string(/** @scrutinizer ignore-type */ $this->csv); |
| 364 | - if(!$result) { |
|
| 364 | + if (!$result) { |
|
| 365 | 365 | $this->addError('The CSV string could not be parsed.'); |
| 366 | 366 | return; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - switch($this->headersPosition) |
|
| 369 | + switch ($this->headersPosition) |
|
| 370 | 370 | { |
| 371 | 371 | case self::HEADERS_TOP: |
| 372 | 372 | $this->headers = array_shift($result); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | case self::HEADERS_LEFT: |
| 376 | 376 | $keep = array(); |
| 377 | 377 | $total = count($result); |
| 378 | - for($i=0; $i < $total; $i++) { |
|
| 378 | + for ($i = 0; $i < $total; $i++) { |
|
| 379 | 379 | $row = $result[$i]; |
| 380 | 380 | $this->headers[] = array_shift($row); |
| 381 | 381 | $keep[] = $row; |
@@ -388,9 +388,9 @@ discard block |
||
| 388 | 388 | $this->data = $result; |
| 389 | 389 | $this->rowCount = count($this->data); |
| 390 | 390 | |
| 391 | - for($i=0; $i < $this->rowCount; $i++) { |
|
| 391 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
| 392 | 392 | $amount = count($this->data[$i]); |
| 393 | - if($amount > $this->columnCount) { |
|
| 393 | + if ($amount > $this->columnCount) { |
|
| 394 | 394 | $this->columnCount = $amount; |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | ',,' => ',' |
| 435 | 435 | ); |
| 436 | 436 | |
| 437 | - foreach($search as $char => $separator) { |
|
| 438 | - if(strstr($this->csv, $char)) { |
|
| 437 | + foreach ($search as $char => $separator) { |
|
| 438 | + if (strstr($this->csv, $char)) { |
|
| 439 | 439 | return $separator; |
| 440 | 440 | } |
| 441 | 441 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getNextPage() : int |
| 115 | 115 | { |
| 116 | - if($this->next === 0) { |
|
| 116 | + if ($this->next === 0) { |
|
| 117 | 117 | return $this->last; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function getPreviousPage() : int |
| 139 | 139 | { |
| 140 | - if($this->prev === 0) { |
|
| 140 | + if ($this->prev === 0) { |
|
| 141 | 141 | return 1; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | // adjust the adjacent value if it exceeds the |
| 183 | 183 | // total amount of pages |
| 184 | 184 | $adjacentTotal = ($adjacent * 2) + 1; |
| 185 | - if($adjacentTotal > $this->last) |
|
| 185 | + if ($adjacentTotal > $this->last) |
|
| 186 | 186 | { |
| 187 | 187 | $adjacent = (int)floor($this->last / 2); |
| 188 | 188 | } |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | $back = 0; |
| 196 | 196 | $fwd = 0; |
| 197 | 197 | |
| 198 | - if($maxBack >= $adjacent) { |
|
| 198 | + if ($maxBack >= $adjacent) { |
|
| 199 | 199 | $back = $adjacent; |
| 200 | 200 | } else { |
| 201 | 201 | $back = $maxBack; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if($maxFwd >= $adjacent) { |
|
| 204 | + if ($maxFwd >= $adjacent) { |
|
| 205 | 205 | $fwd = $adjacent; |
| 206 | 206 | } else { |
| 207 | 207 | $fwd = $maxFwd; |
@@ -217,16 +217,16 @@ discard block |
||
| 217 | 217 | $fwd += $backDiff; |
| 218 | 218 | $back += $fwdDiff; |
| 219 | 219 | |
| 220 | - if($fwd > $maxFwd) { $fwd = $maxFwd; } |
|
| 221 | - if($back > $maxBack) { $back = $maxBack; } |
|
| 220 | + if ($fwd > $maxFwd) { $fwd = $maxFwd; } |
|
| 221 | + if ($back > $maxBack) { $back = $maxBack; } |
|
| 222 | 222 | |
| 223 | 223 | // calculate the first and last page in the list |
| 224 | 224 | $prev = $this->current - $back; |
| 225 | 225 | $next = $this->current + $fwd; |
| 226 | 226 | |
| 227 | 227 | // failsafe so we stay within the bounds |
| 228 | - if($prev < 1) { $prev = 1; } |
|
| 229 | - if($next > $this->last) { $next = $this->last; } |
|
| 228 | + if ($prev < 1) { $prev = 1; } |
|
| 229 | + if ($next > $this->last) { $next = $this->last; } |
|
| 230 | 230 | |
| 231 | 231 | // create and return the page numbers list |
| 232 | 232 | $numbers = range($prev, $next); |
@@ -319,11 +319,11 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | $pages = (int)ceil($this->total / $this->perPage); |
| 321 | 321 | |
| 322 | - if($this->current < 1) |
|
| 322 | + if ($this->current < 1) |
|
| 323 | 323 | { |
| 324 | 324 | $this->current = 1; |
| 325 | 325 | } |
| 326 | - else if($this->current > $pages) |
|
| 326 | + else if ($this->current > $pages) |
|
| 327 | 327 | { |
| 328 | 328 | $this->current = $pages; |
| 329 | 329 | } |
@@ -331,19 +331,19 @@ discard block |
||
| 331 | 331 | $this->last = $pages; |
| 332 | 332 | |
| 333 | 333 | $nextPage = $this->current + 1; |
| 334 | - if($nextPage <= $pages) { |
|
| 334 | + if ($nextPage <= $pages) { |
|
| 335 | 335 | $this->next = $nextPage; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | $prevPage = $this->current - 1; |
| 339 | - if($prevPage > 0) { |
|
| 339 | + if ($prevPage > 0) { |
|
| 340 | 340 | $this->prev = $prevPage; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | $this->offsetStart = ($this->current - 1) * $this->perPage; |
| 344 | 344 | |
| 345 | 345 | $this->offsetEnd = $this->offsetStart + $this->perPage; |
| 346 | - if($this->offsetEnd > ($this->total - 1)) { |
|
| 346 | + if ($this->offsetEnd > ($this->total - 1)) { |
|
| 347 | 347 | $this->offsetEnd = ($this->total - 1); |
| 348 | 348 | } |
| 349 | 349 | } |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | public function getParam($name, $default = null) |
| 75 | 75 | { |
| 76 | 76 | $value = $default; |
| 77 | - if(isset($_REQUEST[$name])) { |
|
| 77 | + if (isset($_REQUEST[$name])) { |
|
| 78 | 78 | $value = $_REQUEST[$name]; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if(isset($this->knownParams[$name])) { |
|
| 81 | + if (isset($this->knownParams[$name])) { |
|
| 82 | 82 | $value = $this->knownParams[$name]->validate($value); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function getRefreshParams($params = array(), $exclude = array()) |
| 123 | 123 | { |
| 124 | - if(empty($params)) { $params = array(); } |
|
| 125 | - if(empty($exclude)) { $exclude = array(); } |
|
| 124 | + if (empty($params)) { $params = array(); } |
|
| 125 | + if (empty($exclude)) { $exclude = array(); } |
|
| 126 | 126 | |
| 127 | 127 | $vars = $_REQUEST; |
| 128 | 128 | |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | // remove the quickform form variable if present, to |
| 143 | 143 | // avoid redirect loops when using the refresh URL in |
| 144 | 144 | // a page in which a form has been submitted. |
| 145 | - foreach($names as $name) { |
|
| 146 | - if(strstr($name, '_qf__')) { |
|
| 145 | + foreach ($names as $name) { |
|
| 146 | + if (strstr($name, '_qf__')) { |
|
| 147 | 147 | unset($vars[$name]); |
| 148 | 148 | break; |
| 149 | 149 | } |
@@ -170,13 +170,13 @@ discard block |
||
| 170 | 170 | * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed. |
| 171 | 171 | * @return string |
| 172 | 172 | */ |
| 173 | - public function buildURL($params = array(), string $dispatcher='') |
|
| 173 | + public function buildURL($params = array(), string $dispatcher = '') |
|
| 174 | 174 | { |
| 175 | - $url = rtrim(APP_URL, '/') . '/' . $dispatcher; |
|
| 175 | + $url = rtrim(APP_URL, '/').'/'.$dispatcher; |
|
| 176 | 176 | |
| 177 | 177 | // append any leftover parameters to the end of the URL |
| 178 | 178 | if (!empty($params)) { |
| 179 | - $url .= '?' . http_build_query($params, null, '&'); |
|
| 179 | + $url .= '?'.http_build_query($params, null, '&'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | return $url; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function registerParam($name) |
| 194 | 194 | { |
| 195 | - if(!isset($this->knownParams[$name])) { |
|
| 195 | + if (!isset($this->knownParams[$name])) { |
|
| 196 | 196 | $param = new Request_Param($this, $name); |
| 197 | 197 | $this->knownParams[$name] = $param; |
| 198 | 198 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function getRegisteredParam(string $name) : Request_Param |
| 211 | 211 | { |
| 212 | - if(isset($this->knownParams[$name])) { |
|
| 212 | + if (isset($this->knownParams[$name])) { |
|
| 213 | 213 | return $this->knownParams[$name]; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -276,12 +276,12 @@ discard block |
||
| 276 | 276 | { |
| 277 | 277 | $entry['type'] = $matches[1]; |
| 278 | 278 | |
| 279 | - if(isset($matches[2]) && !empty($matches[2])) |
|
| 279 | + if (isset($matches[2]) && !empty($matches[2])) |
|
| 280 | 280 | { |
| 281 | 281 | $params = ConvertHelper::parseQueryString($matches[2]); |
| 282 | 282 | $entry['params'] = $params; |
| 283 | 283 | |
| 284 | - if(isset($params['q'])) { |
|
| 284 | + if (isset($params['q'])) { |
|
| 285 | 285 | $entry['quality'] = (double)$params['q']; |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | { |
| 335 | 335 | $_REQUEST[$name] = $value; |
| 336 | 336 | |
| 337 | - if(isset($this->knownParams[$name])) { |
|
| 337 | + if (isset($this->knownParams[$name])) { |
|
| 338 | 338 | unset($this->knownParams[$name]); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -368,11 +368,11 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | public function removeParam(string $name) : Request |
| 370 | 370 | { |
| 371 | - if(isset($_REQUEST[$name])) { |
|
| 371 | + if (isset($_REQUEST[$name])) { |
|
| 372 | 372 | unset($_REQUEST[$name]); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if(isset($this->knownParams[$name])) { |
|
| 375 | + if (isset($this->knownParams[$name])) { |
|
| 376 | 376 | unset($this->knownParams[$name]); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | public function removeParams(array $names) : Request |
| 389 | 389 | { |
| 390 | - foreach($names as $name) { |
|
| 390 | + foreach ($names as $name) { |
|
| 391 | 391 | $this->removeParam($name); |
| 392 | 392 | } |
| 393 | 393 | |
@@ -403,10 +403,10 @@ discard block |
||
| 403 | 403 | * @param string $name |
| 404 | 404 | * @return bool |
| 405 | 405 | */ |
| 406 | - public function getBool($name, $default=false) |
|
| 406 | + public function getBool($name, $default = false) |
|
| 407 | 407 | { |
| 408 | 408 | $value = $this->getParam($name, $default); |
| 409 | - if(ConvertHelper::isBoolean($value)) { |
|
| 409 | + if (ConvertHelper::isBoolean($value)) { |
|
| 410 | 410 | return ConvertHelper::string2bool($value); |
| 411 | 411 | } |
| 412 | 412 | |
@@ -415,9 +415,9 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | public function validate() |
| 417 | 417 | { |
| 418 | - foreach($this->knownParams as $param) { |
|
| 418 | + foreach ($this->knownParams as $param) { |
|
| 419 | 419 | $name = $param->getName(); |
| 420 | - if($param->isRequired() && !$this->hasParam($name)) { |
|
| 420 | + if ($param->isRequired() && !$this->hasParam($name)) { |
|
| 421 | 421 | throw new Request_Exception( |
| 422 | 422 | 'Missing request parameter '.$name, |
| 423 | 423 | sprintf( |
@@ -439,10 +439,10 @@ discard block |
||
| 439 | 439 | * @param mixed $default |
| 440 | 440 | * @return string |
| 441 | 441 | */ |
| 442 | - public function getFilteredParam($name, $default=null) |
|
| 442 | + public function getFilteredParam($name, $default = null) |
|
| 443 | 443 | { |
| 444 | 444 | $val = $this->getParam($name, $default); |
| 445 | - if(is_string($val)) { |
|
| 445 | + if (is_string($val)) { |
|
| 446 | 446 | $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8'); |
| 447 | 447 | } |
| 448 | 448 | |
@@ -461,24 +461,24 @@ discard block |
||
| 461 | 461 | * @see Request::getJSONAssoc() |
| 462 | 462 | * @see Request::getJSONObject() |
| 463 | 463 | */ |
| 464 | - public function getJSON(string $name, bool $assoc=true) |
|
| 464 | + public function getJSON(string $name, bool $assoc = true) |
|
| 465 | 465 | { |
| 466 | 466 | $value = $this->getParam($name); |
| 467 | 467 | |
| 468 | - if(!empty($value) && is_string($value)) |
|
| 468 | + if (!empty($value) && is_string($value)) |
|
| 469 | 469 | { |
| 470 | 470 | $data = json_decode($value, $assoc); |
| 471 | 471 | |
| 472 | - if($assoc && is_array($data)) { |
|
| 472 | + if ($assoc && is_array($data)) { |
|
| 473 | 473 | return $data; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - if(is_object($data)) { |
|
| 476 | + if (is_object($data)) { |
|
| 477 | 477 | return $data; |
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if($assoc) { |
|
| 481 | + if ($assoc) { |
|
| 482 | 482 | return array(); |
| 483 | 483 | } |
| 484 | 484 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | public function getJSONAssoc(string $name) : array |
| 496 | 496 | { |
| 497 | 497 | $result = $this->getJSON($name); |
| 498 | - if(is_array($result)) { |
|
| 498 | + if (is_array($result)) { |
|
| 499 | 499 | return $result; |
| 500 | 500 | } |
| 501 | 501 | |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | public function getJSONObject(string $name) : object |
| 513 | 513 | { |
| 514 | 514 | $result = $this->getJSON($name, false); |
| 515 | - if(is_object($result)) { |
|
| 515 | + if (is_object($result)) { |
|
| 516 | 516 | return $result; |
| 517 | 517 | } |
| 518 | 518 | |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | * @param array|string $data |
| 526 | 526 | * @param bool $exit Whether to exit the script afterwards. |
| 527 | 527 | */ |
| 528 | - public static function sendJSON($data, bool $exit=true) |
|
| 528 | + public static function sendJSON($data, bool $exit = true) |
|
| 529 | 529 | { |
| 530 | 530 | $payload = $data; |
| 531 | - if(!is_string($payload)) { |
|
| 531 | + if (!is_string($payload)) { |
|
| 532 | 532 | $payload = json_encode($payload); |
| 533 | 533 | } |
| 534 | 534 | |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | echo $payload; |
| 540 | 540 | |
| 541 | - if($exit) |
|
| 541 | + if ($exit) |
|
| 542 | 542 | { |
| 543 | 543 | exit; |
| 544 | 544 | } |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | * @param string $html |
| 551 | 551 | * @param bool $exit Whether to exit the script afterwards. |
| 552 | 552 | */ |
| 553 | - public static function sendHTML(string $html, bool $exit=true) |
|
| 553 | + public static function sendHTML(string $html, bool $exit = true) |
|
| 554 | 554 | { |
| 555 | 555 | header('Cache-Control: no-cache, must-revalidate'); |
| 556 | 556 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | echo $html; |
| 560 | 560 | |
| 561 | - if($exit) |
|
| 561 | + if ($exit) |
|
| 562 | 562 | { |
| 563 | 563 | exit; |
| 564 | 564 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
| 575 | 575 | * @return Request_URLComparer |
| 576 | 576 | */ |
| 577 | - public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
|
| 577 | + public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer |
|
| 578 | 578 | { |
| 579 | 579 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
| 580 | 580 | $comparer->addLimitParams($limitParams); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | protected function __construct($subject) |
| 63 | 63 | { |
| 64 | - if(is_array($subject)) |
|
| 64 | + if (is_array($subject)) |
|
| 65 | 65 | { |
| 66 | 66 | $this->parseSerialized($subject); |
| 67 | 67 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function getPrevious() : ConvertHelper_ThrowableInfo |
| 117 | 117 | { |
| 118 | - if(isset($this->previous)) { |
|
| 118 | + if (isset($this->previous)) { |
|
| 119 | 119 | return $this->previous; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | $string = 'Exception'; |
| 142 | 142 | |
| 143 | - if($this->hasCode()) { |
|
| 143 | + if ($this->hasCode()) { |
|
| 144 | 144 | $string .= ' #'.$this->code; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $string .= ': '.$this->getMessage().PHP_EOL; |
| 148 | 148 | |
| 149 | - foreach($calls as $call) |
|
| 149 | + foreach ($calls as $call) |
|
| 150 | 150 | { |
| 151 | 151 | $string .= $call->toString().PHP_EOL; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if($this->hasPrevious()) |
|
| 154 | + if ($this->hasPrevious()) |
|
| 155 | 155 | { |
| 156 | 156 | $string .= PHP_EOL.PHP_EOL. |
| 157 | 157 | 'Previous error:'.PHP_EOL.PHP_EOL. |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | 'previous' => null, |
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | - if($this->hasPrevious()) { |
|
| 246 | - $result['previous'] = $this->previous->serialize(); |
|
| 245 | + if ($this->hasPrevious()) { |
|
| 246 | + $result['previous'] = $this->previous->serialize(); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - foreach($this->calls as $call) |
|
| 249 | + foreach ($this->calls as $call) |
|
| 250 | 250 | { |
| 251 | 251 | $result['calls'][] = $call->serialize(); |
| 252 | 252 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | public function getFolderDepth() : int |
| 276 | 276 | { |
| 277 | 277 | $depth = $this->getOption('folder-depth'); |
| 278 | - if(!empty($depth)) { |
|
| 278 | + if (!empty($depth)) { |
|
| 279 | 279 | return $depth; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | $this->setOptions($serialized['options']); |
| 313 | 313 | |
| 314 | - if(!empty($serialized['previous'])) |
|
| 314 | + if (!empty($serialized['previous'])) |
|
| 315 | 315 | { |
| 316 | 316 | $this->previous = ConvertHelper_ThrowableInfo::fromSerialized($serialized['previous']); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - foreach($serialized['calls'] as $def) |
|
| 319 | + foreach ($serialized['calls'] as $def) |
|
| 320 | 320 | { |
| 321 | 321 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromSerialized($this, $def); |
| 322 | 322 | } |
@@ -328,16 +328,16 @@ discard block |
||
| 328 | 328 | $this->message = $e->getMessage(); |
| 329 | 329 | $this->code = intval($e->getCode()); |
| 330 | 330 | |
| 331 | - if(!isset($_REQUEST) || !isset($_REQUEST['REQUEST_URI'])) { |
|
| 331 | + if (!isset($_REQUEST) || !isset($_REQUEST['REQUEST_URI'])) { |
|
| 332 | 332 | $this->context = self::CONTEXT_COMMAND_LINE; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | $previous = $e->getPrevious(); |
| 336 | - if(!empty($previous)) { |
|
| 336 | + if (!empty($previous)) { |
|
| 337 | 337 | $this->previous = ConvertHelper::throwable2info($previous); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if(isset($_SERVER) && isset($_SERVER['REQUEST_URI'])) { |
|
| 340 | + if (isset($_SERVER) && isset($_SERVER['REQUEST_URI'])) { |
|
| 341 | 341 | $this->referer = $_SERVER['REQUEST_URI']; |
| 342 | 342 | } |
| 343 | 343 | |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | $idx = 1; |
| 353 | 353 | |
| 354 | - foreach($trace as $entry) |
|
| 354 | + foreach ($trace as $entry) |
|
| 355 | 355 | { |
| 356 | 356 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromTrace($this, $idx, $entry); |
| 357 | 357 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @see FileHelper_FileFinder |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace AppUtils; |
| 13 | 13 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | public function getAll() : array |
| 127 | 127 | { |
| 128 | - if(!isset($this->found)) { |
|
| 128 | + if (!isset($this->found)) { |
|
| 129 | 129 | $this->find($this->path, true); |
| 130 | 130 | } |
| 131 | 131 | |
@@ -150,25 +150,25 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | protected $found; |
| 152 | 152 | |
| 153 | - protected function find($path, $isRoot=false) |
|
| 153 | + protected function find($path, $isRoot = false) |
|
| 154 | 154 | { |
| 155 | - if($isRoot) { |
|
| 155 | + if ($isRoot) { |
|
| 156 | 156 | $this->found = array(); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $d = new \DirectoryIterator($path); |
| 160 | - foreach($d as $item) |
|
| 160 | + foreach ($d as $item) |
|
| 161 | 161 | { |
| 162 | - if($item->isDir()) |
|
| 162 | + if ($item->isDir()) |
|
| 163 | 163 | { |
| 164 | - if($this->getOption('recursive') === true && !$item->isDot()) { |
|
| 164 | + if ($this->getOption('recursive') === true && !$item->isDot()) { |
|
| 165 | 165 | $this->find($item->getPathname()); |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | 170 | $file = $this->filterFile($item->getPathname()); |
| 171 | - if($file) { |
|
| 171 | + if ($file) { |
|
| 172 | 172 | $this->found[] = $file; |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -184,20 +184,20 @@ discard block |
||
| 184 | 184 | $include = $this->getOption('include-extensions'); |
| 185 | 185 | $exclude = $this->getOption('exclude-extensions'); |
| 186 | 186 | |
| 187 | - if(!empty($include)) |
|
| 187 | + if (!empty($include)) |
|
| 188 | 188 | { |
| 189 | - if(!in_array($info['extension'], $include)) { |
|
| 189 | + if (!in_array($info['extension'], $include)) { |
|
| 190 | 190 | return false; |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | - else if(!empty($exclude)) |
|
| 193 | + else if (!empty($exclude)) |
|
| 194 | 194 | { |
| 195 | - if(in_array($info['extension'], $exclude)) { |
|
| 195 | + if (in_array($info['extension'], $exclude)) { |
|
| 196 | 196 | return false; |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - switch($this->getOption('pathmode')) |
|
| 200 | + switch ($this->getOption('pathmode')) |
|
| 201 | 201 | { |
| 202 | 202 | case self::PATH_MODE_STRIP: |
| 203 | 203 | $path = basename($path); |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | break; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if($this->getOption('strip-extensions') === true) |
|
| 216 | + if ($this->getOption('strip-extensions') === true) |
|
| 217 | 217 | { |
| 218 | 218 | $path = str_replace('.'.$info['extension'], '', $path); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | $replace = $this->getOption('slash-replacement'); |
| 222 | - if(!empty($replace)) { |
|
| 222 | + if (!empty($replace)) { |
|
| 223 | 223 | $path = str_replace('/', $replace, $path); |
| 224 | 224 | } |
| 225 | 225 | |