@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | $this->subject = $subject; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function setRemoveDuplicates(bool $remove=true, bool $caseInsensitive=false) : self |
|
| 30 | + public function setRemoveDuplicates(bool $remove = true, bool $caseInsensitive = false) : self |
|
| 31 | 31 | { |
| 32 | 32 | $this->removeDuplicates = $remove; |
| 33 | 33 | $this->duplicatesCaseInsensitive = $caseInsensitive; |
| 34 | 34 | return $this; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function setSorting(bool $sorting=true) : self |
|
| 37 | + public function setSorting(bool $sorting = true) : self |
|
| 38 | 38 | { |
| 39 | 39 | $this->sorting = $sorting; |
| 40 | 40 | return $this; |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $words = $this->filterEmpty($words); |
| 57 | 57 | |
| 58 | - if($this->removeDuplicates) { |
|
| 58 | + if ($this->removeDuplicates) { |
|
| 59 | 59 | $words = $this->filterDuplicates($words); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if($this->sorting) { |
|
| 62 | + if ($this->sorting) { |
|
| 63 | 63 | usort($words, 'strnatcasecmp'); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private function filterDuplicates(array $words) : array |
| 74 | 74 | { |
| 75 | - if($this->duplicatesCaseInsensitive) { |
|
| 75 | + if ($this->duplicatesCaseInsensitive) { |
|
| 76 | 76 | return $this->filterDuplicatesCaseInsensitive($words); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | return array_intersect_key( |
| 89 | 89 | $array, |
| 90 | - array_unique( array_map( "strtolower", $array ) ) |
|
| 90 | + array_unique(array_map("strtolower", $array)) |
|
| 91 | 91 | ); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $keep = array(); |
| 101 | 101 | |
| 102 | - foreach($words as $word) |
|
| 102 | + foreach ($words as $word) |
|
| 103 | 103 | { |
| 104 | - if(empty($word)) { |
|
| 104 | + if (empty($word)) { |
|
| 105 | 105 | continue; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(mb_strlen($word) < $this->minWordLength) { |
|
| 108 | + if (mb_strlen($word) < $this->minWordLength) { |
|
| 109 | 109 | continue; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $this->trimmed = trim($text); |
| 48 | 48 | $this->lineNumber = $lineNumber; |
| 49 | 49 | |
| 50 | - if(empty($this->trimmed)) |
|
| 50 | + if (empty($this->trimmed)) |
|
| 51 | 51 | { |
| 52 | 52 | $this->type = self::TYPE_EMPTY; |
| 53 | 53 | return; |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $startChar = $this->trimmed[0]; |
| 57 | 57 | |
| 58 | - if($startChar === ';') |
|
| 58 | + if ($startChar === ';') |
|
| 59 | 59 | { |
| 60 | 60 | $this->type = self::TYPE_COMMENT; |
| 61 | 61 | } |
| 62 | - else if($startChar === '[') |
|
| 62 | + else if ($startChar === '[') |
|
| 63 | 63 | { |
| 64 | 64 | $this->type = self::TYPE_SECTION_DECLARATION; |
| 65 | 65 | $this->sectionName = trim($this->trimmed, '[]'); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | else |
| 69 | 69 | { |
| 70 | 70 | $pos = strpos($this->trimmed, '='); |
| 71 | - if($pos === false) |
|
| 71 | + if ($pos === false) |
|
| 72 | 72 | { |
| 73 | 73 | $this->type = self::TYPE_INVALID; |
| 74 | 74 | return; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $this->type = self::TYPE_VALUE; |
| 78 | 78 | $this->varName = trim(substr($this->trimmed, 0, $pos)); |
| 79 | 79 | |
| 80 | - $this->parseValue(substr($this->trimmed, $pos+1)); |
|
| 80 | + $this->parseValue(substr($this->trimmed, $pos + 1)); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | $this->varValue = trim($value); |
| 87 | 87 | $value = $this->varValue; |
| 88 | 88 | |
| 89 | - if(empty($value)) { |
|
| 89 | + if (empty($value)) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if($value[0] === '"' && $value[strlen($value) - 1] === '"') |
|
| 93 | + if ($value[0] === '"' && $value[strlen($value) - 1] === '"') |
|
| 94 | 94 | { |
| 95 | 95 | $value = trim($value, '"'); |
| 96 | 96 | $this->quoteStyle = '"'; |
| 97 | 97 | } |
| 98 | - else if($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
| 98 | + else if ($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
| 99 | 99 | { |
| 100 | 100 | $value = trim($value, "'"); |
| 101 | 101 | $this->quoteStyle = "'"; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | public function getQuotedVarValue() : string |
| 118 | 118 | { |
| 119 | - if($this->quoteStyle === '') { |
|
| 119 | + if ($this->quoteStyle === '') { |
|
| 120 | 120 | return $this->getVarValue(); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function setValue($value) : INILine |
| 177 | 177 | { |
| 178 | - if(!is_null($value) && !is_scalar($value)) |
|
| 178 | + if (!is_null($value) && !is_scalar($value)) |
|
| 179 | 179 | { |
| 180 | 180 | throw new IniHelper_Exception( |
| 181 | 181 | 'Cannot use non-scalar values.', |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | public function toString() : string |
| 197 | 197 | { |
| 198 | - switch($this->type) |
|
| 198 | + switch ($this->type) |
|
| 199 | 199 | { |
| 200 | 200 | case self::TYPE_EMPTY: |
| 201 | 201 | case self::TYPE_INVALID: |
@@ -58,14 +58,12 @@ discard block |
||
| 58 | 58 | if($startChar === ';') |
| 59 | 59 | { |
| 60 | 60 | $this->type = self::TYPE_COMMENT; |
| 61 | - } |
|
| 62 | - else if($startChar === '[') |
|
| 61 | + } else if($startChar === '[') |
|
| 63 | 62 | { |
| 64 | 63 | $this->type = self::TYPE_SECTION_DECLARATION; |
| 65 | 64 | $this->sectionName = trim($this->trimmed, '[]'); |
| 66 | 65 | $this->sectionName = trim($this->sectionName); // remove any whitespace |
| 67 | - } |
|
| 68 | - else |
|
| 66 | + } else |
|
| 69 | 67 | { |
| 70 | 68 | $pos = strpos($this->trimmed, '='); |
| 71 | 69 | if($pos === false) |
@@ -94,8 +92,7 @@ discard block |
||
| 94 | 92 | { |
| 95 | 93 | $value = trim($value, '"'); |
| 96 | 94 | $this->quoteStyle = '"'; |
| 97 | - } |
|
| 98 | - else if($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
| 95 | + } else if($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
| 99 | 96 | { |
| 100 | 97 | $value = trim($value, "'"); |
| 101 | 98 | $this->quoteStyle = "'"; |
@@ -27,9 +27,9 @@ |
||
| 27 | 27 | protected RequestParam $param; |
| 28 | 28 | protected bool $isSubvalue = false; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var mixed|NULL |
|
| 32 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var mixed|NULL |
|
| 32 | + */ |
|
| 33 | 33 | protected $value; |
| 34 | 34 | |
| 35 | 35 | public function __construct(RequestParam $param, bool $subval) |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | protected function _filter() : string |
| 22 | 22 | { |
| 23 | - if(!is_scalar($this->value)) { |
|
| 23 | + if (!is_scalar($this->value)) { |
|
| 24 | 24 | return ''; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | protected function _filter() : array |
| 28 | 28 | { |
| 29 | - if(is_array($this->value)) { |
|
| 29 | + if (is_array($this->value)) { |
|
| 30 | 30 | return $this->value; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if($this->value === '' || !is_string($this->value)) { |
|
| 33 | + if ($this->value === '' || !is_string($this->value)) { |
|
| 34 | 34 | return array(); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | $stripEmptyEntries = $this->getBoolOption('stripEmptyEntries'); |
| 39 | 39 | $result = explode(',', $this->value); |
| 40 | 40 | |
| 41 | - if(!$trimEntries && !$stripEmptyEntries) { |
|
| 41 | + if (!$trimEntries && !$stripEmptyEntries) { |
|
| 42 | 42 | return $result; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $keep = array(); |
| 46 | 46 | |
| 47 | - foreach($result as $entry) |
|
| 47 | + foreach ($result as $entry) |
|
| 48 | 48 | { |
| 49 | - if($trimEntries === true) { |
|
| 49 | + if ($trimEntries === true) { |
|
| 50 | 50 | $entry = trim($entry); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if($stripEmptyEntries === true && $entry === '') { |
|
| 53 | + if ($stripEmptyEntries === true && $entry === '') { |
|
| 54 | 54 | continue; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | protected function _validate() |
| 34 | 34 | { |
| 35 | - if(in_array($this->value, $this->getArrayOption('values'), true)) { |
|
| 35 | + if (in_array($this->value, $this->getArrayOption('values'), true)) { |
|
| 36 | 36 | return $this->value; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | protected function _validate() : ?int |
| 32 | 32 | { |
| 33 | - if(ConvertHelper::isInteger($this->value)) { |
|
| 33 | + if (ConvertHelper::isInteger($this->value)) { |
|
| 34 | 34 | return (int)$this->value; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -27,13 +27,13 @@ |
||
| 27 | 27 | |
| 28 | 28 | protected function _validate() : ?string |
| 29 | 29 | { |
| 30 | - if(!is_scalar($this->value)) { |
|
| 30 | + if (!is_scalar($this->value)) { |
|
| 31 | 31 | return null; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $value = (string)$this->value; |
| 35 | 35 | |
| 36 | - if(preg_match('/\A[a-zA-Z]+\z/', $value)) { |
|
| 36 | + if (preg_match('/\A[a-zA-Z]+\z/', $value)) { |
|
| 37 | 37 | return $value; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -36,22 +36,22 @@ |
||
| 36 | 36 | |
| 37 | 37 | // if we are validating a subvalue, it means we are |
| 38 | 38 | // validating a single value in the existing list. |
| 39 | - if($this->isSubvalue) |
|
| 39 | + if ($this->isSubvalue) |
|
| 40 | 40 | { |
| 41 | - if(in_array($this->value, $allowed, true)) { |
|
| 41 | + if (in_array($this->value, $allowed, true)) { |
|
| 42 | 42 | return $this->value; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | return null; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if(!is_array($this->value)) { |
|
| 48 | + if (!is_array($this->value)) { |
|
| 49 | 49 | return array(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $keep = array(); |
| 53 | - foreach($this->value as $item) { |
|
| 54 | - if(in_array($item, $allowed, true)) { |
|
| 53 | + foreach ($this->value as $item) { |
|
| 54 | + if (in_array($item, $allowed, true)) { |
|
| 55 | 55 | $keep[] = $item; |
| 56 | 56 | } |
| 57 | 57 | } |