@@ -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 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param int $code |
32 | 32 | * @param \Exception $previous |
33 | 33 | */ |
34 | - public function __construct(string $message, $details=null, $code=null, $previous=null) |
|
34 | + public function __construct(string $message, $details = null, $code = null, $previous = null) |
|
35 | 35 | { |
36 | 36 | parent::__construct($message, $code, $previous); |
37 | 37 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getDetails() : string |
46 | 46 | { |
47 | - if($this->details !== null) { |
|
47 | + if ($this->details !== null) { |
|
48 | 48 | return $this->details; |
49 | 49 | } |
50 | 50 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function display() |
59 | 59 | { |
60 | - if(!headers_sent()) { |
|
60 | + if (!headers_sent()) { |
|
61 | 61 | header('Content-type:text/plain; charset=utf-8'); |
62 | 62 | } |
63 | 63 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | throw new BaseException(''); |
87 | 87 | } |
88 | - catch(BaseException $e) |
|
88 | + catch (BaseException $e) |
|
89 | 89 | { |
90 | 90 | echo self::createInfo($e)->toString(); |
91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | { |
101 | 101 | throw new BaseException(''); |
102 | 102 | } |
103 | - catch(BaseException $e) |
|
103 | + catch (BaseException $e) |
|
104 | 104 | { |
105 | 105 | echo '<pre style="background:#fff;font-family:monospace;font-size:14px;color:#444;padding:16px;border:solid 1px #999;border-radius:4px;">'; |
106 | 106 | echo self::createInfo($e)->toString(); |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | { |
36 | 36 | $section = $this->addSection(self::SECTION_DEFAULT); |
37 | 37 | |
38 | - if(empty($iniString)) { |
|
38 | + if (empty($iniString)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $eol = ConvertHelper::detectEOLCharacter($iniString); |
43 | - if($eol !== null) { |
|
43 | + if ($eol !== null) { |
|
44 | 44 | $this->eol = $eol->getCharacter(); |
45 | 45 | } |
46 | 46 | |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | |
49 | 49 | $total = count($lines); |
50 | 50 | |
51 | - for($i=0; $i < $total; $i++) |
|
51 | + for ($i = 0; $i < $total; $i++) |
|
52 | 52 | { |
53 | 53 | $line = new IniHelper_Line($lines[$i], $i); |
54 | 54 | |
55 | - if($line->isSection()) { |
|
55 | + if ($line->isSection()) { |
|
56 | 56 | $section = $this->addSection($line->getSectionName()); |
57 | 57 | } |
58 | 58 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $iniPath = FileHelper::requireFileExists($iniPath); |
83 | 83 | |
84 | 84 | $content = file_get_contents($iniPath); |
85 | - if($content !== false) { |
|
85 | + if ($content !== false) { |
|
86 | 86 | return self::createFromString($content); |
87 | 87 | } |
88 | 88 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function addSection(string $name) : IniHelper_Section |
129 | 129 | { |
130 | - if(!isset($this->sections[$name])) { |
|
130 | + if (!isset($this->sections[$name])) { |
|
131 | 131 | $this->sections[$name] = new IniHelper_Section($this, $name); |
132 | 132 | } |
133 | 133 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function getSection(string $name) : ?IniHelper_Section |
144 | 144 | { |
145 | - if(isset($this->sections[$name])) { |
|
145 | + if (isset($this->sections[$name])) { |
|
146 | 146 | return $this->sections[$name]; |
147 | 147 | } |
148 | 148 | |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | { |
159 | 159 | $result = array(); |
160 | 160 | |
161 | - foreach($this->sections as $section) |
|
161 | + foreach ($this->sections as $section) |
|
162 | 162 | { |
163 | - if($section->isDefault()) |
|
163 | + if ($section->isDefault()) |
|
164 | 164 | { |
165 | 165 | $result = array_merge($result, $section->toArray()); |
166 | 166 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | { |
201 | 201 | $parts = array(); |
202 | 202 | |
203 | - foreach($this->sections as $section) |
|
203 | + foreach ($this->sections as $section) |
|
204 | 204 | { |
205 | 205 | $parts[] = $section->toString(); |
206 | 206 | } |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function sectionExists(string $name) : bool |
245 | 245 | { |
246 | - foreach($this->sections as $section) { |
|
247 | - if($section->getName() === $name) { |
|
246 | + foreach ($this->sections as $section) { |
|
247 | + if ($section->getName() === $name) { |
|
248 | 248 | return true; |
249 | 249 | } |
250 | 250 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | { |
274 | 274 | $path = $this->parsePath($path); |
275 | 275 | |
276 | - if(!$this->sectionExists($path['section'])) { |
|
276 | + if (!$this->sectionExists($path['section'])) { |
|
277 | 277 | return array(); |
278 | 278 | } |
279 | 279 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | { |
285 | 285 | $path = explode($this->pathSeparator, $path); |
286 | 286 | |
287 | - if(count($path) === 1) |
|
287 | + if (count($path) === 1) |
|
288 | 288 | { |
289 | 289 | return array( |
290 | 290 | 'section' => self::SECTION_DEFAULT, |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | * @param mixed $value |
52 | 52 | * @param array|null $serialized |
53 | 53 | */ |
54 | - public function __construct($value, $serialized=null) |
|
54 | + public function __construct($value, $serialized = null) |
|
55 | 55 | { |
56 | - if(is_array($serialized)) |
|
56 | + if (is_array($serialized)) |
|
57 | 57 | { |
58 | 58 | $this->parseSerialized($serialized); |
59 | 59 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $this->value = $value; |
102 | 102 | $this->type = strtolower(gettype($value)); |
103 | 103 | |
104 | - if(is_array($value) && is_callable($value)) { |
|
104 | + if (is_array($value) && is_callable($value)) { |
|
105 | 105 | $this->type = self::TYPE_CALLABLE; |
106 | 106 | } |
107 | 107 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param bool $enable |
135 | 135 | * @return VariableInfo |
136 | 136 | */ |
137 | - public function enableType(bool $enable=true) : VariableInfo |
|
137 | + public function enableType(bool $enable = true) : VariableInfo |
|
138 | 138 | { |
139 | 139 | return $this->setOption('prepend-type', $enable); |
140 | 140 | } |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | { |
144 | 144 | $converted = $this->string; |
145 | 145 | |
146 | - if($this->getOption('prepend-type') === true && !$this->isNull()) |
|
146 | + if ($this->getOption('prepend-type') === true && !$this->isNull()) |
|
147 | 147 | { |
148 | - if($this->isString()) |
|
148 | + if ($this->isString()) |
|
149 | 149 | { |
150 | 150 | $converted = '"'.$converted.'"'; |
151 | 151 | } |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | |
178 | 178 | $converted = $this->$varMethod(); |
179 | 179 | |
180 | - if($format === 'HTML') |
|
180 | + if ($format === 'HTML') |
|
181 | 181 | { |
182 | 182 | $converted = '<span style="color:#'.self::$colors[$type].'" class="variable-value-'.$this->type.'">'.$converted.'</span>'; |
183 | 183 | } |
184 | 184 | |
185 | - if($this->getOption('prepend-type') === true && !$this->isNull()) |
|
185 | + if ($this->getOption('prepend-type') === true && !$this->isNull()) |
|
186 | 186 | { |
187 | 187 | $typeLabel = $type; |
188 | 188 | |
189 | - switch($format) |
|
189 | + switch ($format) |
|
190 | 190 | { |
191 | 191 | case 'HTML': |
192 | 192 | $typeLabel = '<span style="color:#1c2eb1" class="variable-type">'.$type.'</span> '; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | // the array may not be encodable - for example if it contains |
217 | 217 | // broken unicode characters. |
218 | - if(is_string($result) && $result !== '') { |
|
218 | + if (is_string($result) && $result !== '') { |
|
219 | 219 | return $result; |
220 | 220 | } |
221 | 221 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | $string = ''; |
228 | 228 | |
229 | - if(is_string($this->value[0])) { |
|
229 | + if (is_string($this->value[0])) { |
|
230 | 230 | $string .= $this->value[0].'::'; |
231 | 231 | } else { |
232 | 232 | $string .= get_class($this->value[0]).'->'; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | str_replace(' ', '-', $this->type) |
354 | 354 | ); |
355 | 355 | |
356 | - if($this->getOption('prepend-type') === true && !$this->isNull()) |
|
356 | + if ($this->getOption('prepend-type') === true && !$this->isNull()) |
|
357 | 357 | { |
358 | 358 | $typeLabel = '<span style="color:#1c2eb1" class="variable-type">'.$this->type.'</span> '; |
359 | 359 | $converted = $typeLabel.' '.$converted; |
@@ -95,20 +95,20 @@ discard block |
||
95 | 95 | $quoteStyle = array_shift($params); |
96 | 96 | $method = array_shift($params); |
97 | 97 | |
98 | - $call = $method . '('; |
|
98 | + $call = $method.'('; |
|
99 | 99 | |
100 | 100 | $total = count($params); |
101 | - if($total > 0) { |
|
102 | - for($i=0; $i < $total; $i++) |
|
101 | + if ($total > 0) { |
|
102 | + for ($i = 0; $i < $total; $i++) |
|
103 | 103 | { |
104 | 104 | $call .= self::phpVariable2JS($params[$i], $quoteStyle); |
105 | - if($i < ($total-1)) { |
|
105 | + if ($i < ($total - 1)) { |
|
106 | 106 | $call .= ','; |
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | - return $call . ');'; |
|
111 | + return $call.');'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public static function buildVariable(string $varName, $varValue) : string |
134 | 134 | { |
135 | - return $varName . "=" . self::phpVariable2JS($varValue) . ';'; |
|
135 | + return $varName."=".self::phpVariable2JS($varValue).';'; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param int $quoteStyle The quote style to use for strings |
145 | 145 | * @return string |
146 | 146 | */ |
147 | - public static function phpVariable2JS($variable, int $quoteStyle=self::QUOTE_STYLE_DOUBLE) : string |
|
147 | + public static function phpVariable2JS($variable, int $quoteStyle = self::QUOTE_STYLE_DOUBLE) : string |
|
148 | 148 | { |
149 | 149 | // after much profiling, this variant of the method offers |
150 | 150 | // the best performance. Repeat scalar values are cached |
@@ -152,22 +152,22 @@ discard block |
||
152 | 152 | |
153 | 153 | $type = gettype($variable); |
154 | 154 | $hash = null; |
155 | - if(is_scalar($variable) === true) |
|
155 | + if (is_scalar($variable) === true) |
|
156 | 156 | { |
157 | 157 | $hash = $variable; |
158 | 158 | |
159 | - if($hash === true) |
|
159 | + if ($hash === true) |
|
160 | 160 | { |
161 | 161 | $hash = 'true'; |
162 | 162 | } |
163 | - else if($hash === false) |
|
163 | + else if ($hash === false) |
|
164 | 164 | { |
165 | 165 | $hash = 'false'; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $hash .= '-'.$quoteStyle.'-'.$type; |
169 | 169 | |
170 | - if(isset(self::$variableCache[$hash])) { |
|
170 | + if (isset(self::$variableCache[$hash])) { |
|
171 | 171 | return self::$variableCache[$hash]; |
172 | 172 | } |
173 | 173 | } |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | $result = 'null'; |
176 | 176 | |
177 | 177 | // one gettype call is better than a strict if-else. |
178 | - switch($type) |
|
178 | + switch ($type) |
|
179 | 179 | { |
180 | 180 | case 'double': |
181 | 181 | case 'string': |
182 | 182 | $string = json_encode($variable); |
183 | 183 | |
184 | - if($string === false) |
|
184 | + if ($string === false) |
|
185 | 185 | { |
186 | 186 | $string = ''; |
187 | 187 | } |
188 | - else if($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
188 | + else if ($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
189 | 189 | { |
190 | - $string = mb_substr($string, 1, mb_strlen($string)-2); |
|
190 | + $string = mb_substr($string, 1, mb_strlen($string) - 2); |
|
191 | 191 | $string = "'".str_replace("'", "\'", $string)."'"; |
192 | 192 | } |
193 | 193 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'boolean': |
198 | - if($variable === true) { |
|
198 | + if ($variable === true) { |
|
199 | 199 | $result = 'true'; |
200 | 200 | } else { |
201 | 201 | $result = 'false'; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // cache cacheable values |
216 | - if($hash !== null) |
|
216 | + if ($hash !== null) |
|
217 | 217 | { |
218 | 218 | self::$variableCache[$hash] = $result; |
219 | 219 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | self::$elementCounter++; |
247 | 247 | |
248 | - return self::$idPrefix . self::$elementCounter; |
|
248 | + return self::$idPrefix.self::$elementCounter; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @see JSHelper::JS_REGEX_OBJECT |
320 | 320 | * @see JSHelper::JS_REGEX_JSON |
321 | 321 | */ |
322 | - public static function buildRegexStatement(string $regex, string $statementType=self::JS_REGEX_OBJECT) : string |
|
322 | + public static function buildRegexStatement(string $regex, string $statementType = self::JS_REGEX_OBJECT) : string |
|
323 | 323 | { |
324 | 324 | $regex = trim($regex); |
325 | 325 | $separator = substr($regex, 0, 1); |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | array_shift($parts); |
328 | 328 | |
329 | 329 | $modifiers = array_pop($parts); |
330 | - if($modifiers == $separator) { |
|
330 | + if ($modifiers == $separator) { |
|
331 | 331 | $modifiers = ''; |
332 | 332 | } |
333 | 333 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | // convert the anchors that are not supported in js regexes |
344 | 344 | $format = str_replace(array('\\A', '\\Z', '\\z'), array('^', '$', ''), $format); |
345 | 345 | |
346 | - if($statementType==self::JS_REGEX_JSON) |
|
346 | + if ($statementType == self::JS_REGEX_JSON) |
|
347 | 347 | { |
348 | 348 | return ConvertHelper::var2json(array( |
349 | 349 | 'format' => $format, |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | )); |
352 | 352 | } |
353 | 353 | |
354 | - if(!empty($modifiers)) { |
|
354 | + if (!empty($modifiers)) { |
|
355 | 355 | return sprintf( |
356 | 356 | 'new RegExp(%s, %s)', |
357 | 357 | ConvertHelper::var2json($format), |
@@ -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) : string |
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 | } |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | { |
756 | 756 | $total = count($this->filters); |
757 | 757 | for ($i = 0; $i < $total; $i++) { |
758 | - $method = 'applyFilter_' . $this->filters[$i]['type']; |
|
758 | + $method = 'applyFilter_'.$this->filters[$i]['type']; |
|
759 | 759 | $value = $this->$method($value, $this->filters[$i]['params']); |
760 | 760 | } |
761 | 761 | |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
903 | 903 | * @return \AppUtils\Request_Param |
904 | 904 | */ |
905 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
|
905 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : Request_Param |
|
906 | 906 | { |
907 | 907 | $this->setArray(); |
908 | 908 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function setOption(string $name, $value) |
43 | 43 | { |
44 | - if(!isset($this->options)) { |
|
44 | + if (!isset($this->options)) { |
|
45 | 45 | $this->options = $this->getDefaultOptions(); |
46 | 46 | } |
47 | 47 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setOptions(array $options) |
60 | 60 | { |
61 | - foreach($options as $name => $value) { |
|
61 | + foreach ($options as $name => $value) { |
|
62 | 62 | $this->setOption($name, $value); |
63 | 63 | } |
64 | 64 | |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * @param mixed $default The default value to return if the option does not exist. |
76 | 76 | * @return mixed |
77 | 77 | */ |
78 | - public function getOption(string $name, $default=null) |
|
78 | + public function getOption(string $name, $default = null) |
|
79 | 79 | { |
80 | - if(!isset($this->options)) { |
|
80 | + if (!isset($this->options)) { |
|
81 | 81 | $this->options = $this->getDefaultOptions(); |
82 | 82 | } |
83 | 83 | |
84 | - if(isset($this->options[$name])) { |
|
84 | + if (isset($this->options[$name])) { |
|
85 | 85 | return $this->options[$name]; |
86 | 86 | } |
87 | 87 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param string $default Used if the option does not exist, is invalid, or empty. |
99 | 99 | * @return string |
100 | 100 | */ |
101 | - public function getStringOption(string $name, string $default='') : string |
|
101 | + public function getStringOption(string $name, string $default = '') : string |
|
102 | 102 | { |
103 | 103 | $value = $this->getOption($name, false); |
104 | 104 | |
105 | - if((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
105 | + if ((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
106 | 106 | return (string)$value; |
107 | 107 | } |
108 | 108 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * @param string $name |
119 | 119 | * @return bool |
120 | 120 | */ |
121 | - public function getBoolOption(string $name, bool $default=false) : bool |
|
121 | + public function getBoolOption(string $name, bool $default = false) : bool |
|
122 | 122 | { |
123 | - if($this->getOption($name) === true) { |
|
123 | + if ($this->getOption($name) === true) { |
|
124 | 124 | return true; |
125 | 125 | } |
126 | 126 | |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | * @param int $default |
137 | 137 | * @return int |
138 | 138 | */ |
139 | - public function getIntOption(string $name, int $default=0) : int |
|
139 | + public function getIntOption(string $name, int $default = 0) : int |
|
140 | 140 | { |
141 | 141 | $value = $this->getOption($name); |
142 | - if(ConvertHelper::isInteger($value)) { |
|
142 | + if (ConvertHelper::isInteger($value)) { |
|
143 | 143 | return (int)$value; |
144 | 144 | } |
145 | 145 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public function getArrayOption(string $name) : array |
158 | 158 | { |
159 | 159 | $val = $this->getOption($name); |
160 | - if(is_array($val)) { |
|
160 | + if (is_array($val)) { |
|
161 | 161 | return $val; |
162 | 162 | } |
163 | 163 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function hasOption(string $name) : bool |
175 | 175 | { |
176 | - if(!isset($this->options)) { |
|
176 | + if (!isset($this->options)) { |
|
177 | 177 | $this->options = $this->getDefaultOptions(); |
178 | 178 | } |
179 | 179 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function getOptions() : array |
188 | 188 | { |
189 | - if(!isset($this->options)) { |
|
189 | + if (!isset($this->options)) { |
|
190 | 190 | $this->options = $this->getDefaultOptions(); |
191 | 191 | } |
192 | 192 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param mixed $default |
241 | 241 | * @return Interface_Optionable |
242 | 242 | */ |
243 | - function getOption(string $name, $default=null); |
|
243 | + function getOption(string $name, $default = null); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @param array $options |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // extract parameter names from the query string |
38 | 38 | $result = array(); |
39 | 39 | preg_match_all('/&?([^&]+)=.*/sixU', $queryString, $result, PREG_PATTERN_ORDER); |
40 | - if(isset($result[1])) { |
|
40 | + if (isset($result[1])) { |
|
41 | 41 | $paramNames = $result[1]; |
42 | 42 | } |
43 | 43 | |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | // possible naming conflicts like having both parameters "foo.bar" |
61 | 61 | // and "foo_bar" in the query string: since "foo.bar" would be converted |
62 | 62 | // to "foo_bar", one of the two would be replaced. |
63 | - if($fixRequired) |
|
63 | + if ($fixRequired) |
|
64 | 64 | { |
65 | 65 | $counter = 1; |
66 | 66 | $placeholders = array(); |
67 | - foreach($paramNames as $paramName) |
|
67 | + foreach ($paramNames as $paramName) |
|
68 | 68 | { |
69 | 69 | // create a unique placeholder name |
70 | 70 | $placeholder = '__PLACEHOLDER'.$counter.'__'; |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | parse_str($queryString, $parsed); |
95 | 95 | |
96 | 96 | // do any of the parameter names need to be fixed? |
97 | - if(!$fixRequired) { |
|
97 | + if (!$fixRequired) { |
|
98 | 98 | return $parsed; |
99 | 99 | } |
100 | 100 | |
101 | 101 | $keep = array(); |
102 | 102 | |
103 | - foreach($parsed as $name => $value) |
|
103 | + foreach ($parsed as $name => $value) |
|
104 | 104 | { |
105 | 105 | $keep[$table[$name]] = $value; |
106 | 106 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | return $this->getBoolOption('cut'); |
64 | 64 | } |
65 | 65 | |
66 | - public function setCuttingEnabled(bool $enabled=true) : ConvertHelper_WordWrapper |
|
66 | + public function setCuttingEnabled(bool $enabled = true) : ConvertHelper_WordWrapper |
|
67 | 67 | { |
68 | 68 | $this->setOption('cut', $enabled); |
69 | 69 | return $this; |