@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | protected function _validate() |
29 | 29 | { |
30 | - if(is_array($this->value)) { |
|
30 | + if (is_array($this->value)) { |
|
31 | 31 | return $this->value; |
32 | 32 | } |
33 | 33 |
@@ -29,13 +29,13 @@ |
||
29 | 29 | |
30 | 30 | protected function _validate() |
31 | 31 | { |
32 | - if(!is_array($this->value)) { |
|
32 | + if (!is_array($this->value)) { |
|
33 | 33 | return array(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $keep = array(); |
37 | - foreach($this->value as $item) { |
|
38 | - if(in_array($item, $this->getArrayOption('values'))) { |
|
37 | + foreach ($this->value as $item) { |
|
38 | + if (in_array($item, $this->getArrayOption('values'))) { |
|
39 | 39 | $keep[] = $item; |
40 | 40 | } |
41 | 41 | } |
@@ -29,26 +29,26 @@ |
||
29 | 29 | |
30 | 30 | protected function _validate() |
31 | 31 | { |
32 | - if(!is_string($this->value)) { |
|
32 | + if (!is_string($this->value)) { |
|
33 | 33 | return ''; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $value = trim($this->value); |
37 | 37 | |
38 | - if(empty($value)) { |
|
38 | + if (empty($value)) { |
|
39 | 39 | return ''; |
40 | 40 | } |
41 | 41 | |
42 | 42 | // strictly validate for objects? |
43 | - if($this->getBoolOption('arrays') === false) |
|
43 | + if ($this->getBoolOption('arrays') === false) |
|
44 | 44 | { |
45 | - if(is_object(json_decode($value))) { |
|
45 | + if (is_object(json_decode($value))) { |
|
46 | 46 | return $value; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | else |
50 | 50 | { |
51 | - if(is_array(json_decode($value, true))) { |
|
51 | + if (is_array(json_decode($value, true))) { |
|
52 | 52 | return $value; |
53 | 53 | } |
54 | 54 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | protected function _validate() |
29 | 29 | { |
30 | - if(!is_scalar($this->value)) { |
|
30 | + if (!is_scalar($this->value)) { |
|
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | // is a boolan, which is converted to an integer when |
36 | 36 | // converted to string, which in turn can be validated |
37 | 37 | // with a regex. |
38 | - if(is_bool($this->value)) { |
|
38 | + if (is_bool($this->value)) { |
|
39 | 39 | return null; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $value = (string)$this->value; |
43 | 43 | |
44 | - if(preg_match($this->getStringOption('regex'), $value)) { |
|
44 | + if (preg_match($this->getStringOption('regex'), $value)) { |
|
45 | 45 | return $value; |
46 | 46 | } |
47 | 47 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | protected function _validate() |
31 | 31 | { |
32 | - if(in_array($this->value, $this->getArrayOption('values'))) { |
|
32 | + if (in_array($this->value, $this->getArrayOption('values'))) { |
|
33 | 33 | return $this->value; |
34 | 34 | } |
35 | 35 |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * @param array $args |
127 | 127 | * @return Request_Param |
128 | 128 | */ |
129 | - public function setCallback($callback, array $args=array()) : Request_Param |
|
129 | + public function setCallback($callback, array $args = array()) : Request_Param |
|
130 | 130 | { |
131 | - if(!is_callable($callback)) { |
|
131 | + if (!is_callable($callback)) { |
|
132 | 132 | throw new Request_Exception( |
133 | 133 | 'Not a valid callback', |
134 | 134 | 'The specified callback is not a valid callable entity.', |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | // go through all enqueued validations in turn, each time |
163 | 163 | // replacing the value with the adjusted, validated value. |
164 | - foreach($this->validations as $validateDef) |
|
164 | + foreach ($this->validations as $validateDef) |
|
165 | 165 | { |
166 | 166 | $value = $this->validateType($value, $validateDef['type'], $validateDef['params']); |
167 | 167 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type); |
185 | 185 | |
186 | - if(!class_exists($class)) |
|
186 | + if (!class_exists($class)) |
|
187 | 187 | { |
188 | 188 | throw new Request_Exception( |
189 | 189 | 'Unknown validation type.', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $validator = new $class($this); |
200 | 200 | $validator->setOptions($params); |
201 | 201 | |
202 | - if($this->valueType === self::VALUE_TYPE_ID_LIST) |
|
202 | + if ($this->valueType === self::VALUE_TYPE_ID_LIST) |
|
203 | 203 | { |
204 | 204 | $value = $this->validateType_idList($value, $validator); |
205 | 205 | } |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | |
214 | 214 | protected function validateType_idList($value, Request_Param_Validator $validator) : array |
215 | 215 | { |
216 | - if(!is_array($value)) |
|
216 | + if (!is_array($value)) |
|
217 | 217 | { |
218 | 218 | $value = explode(',', $value); |
219 | 219 | } |
220 | 220 | |
221 | 221 | $keep = array(); |
222 | 222 | |
223 | - foreach($value as $subval) |
|
223 | + foreach ($value as $subval) |
|
224 | 224 | { |
225 | 225 | $subval = trim($subval); |
226 | 226 | $subval = $validator->validate($subval); |
227 | 227 | |
228 | - if($subval !== null) { |
|
228 | + if ($subval !== null) { |
|
229 | 229 | $keep[] = intval($subval); |
230 | 230 | } |
231 | 231 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | { |
366 | 366 | $args = func_get_args(); // cannot be used as function parameter in some PHP versions |
367 | 367 | |
368 | - if(is_array($args[0])) |
|
368 | + if (is_array($args[0])) |
|
369 | 369 | { |
370 | 370 | $args = $args[0]; |
371 | 371 | } |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | * @param mixed $default |
501 | 501 | * @return mixed |
502 | 502 | */ |
503 | - public function get($default=null) |
|
503 | + public function get($default = null) |
|
504 | 504 | { |
505 | 505 | $value = $this->request->getParam($this->paramName); |
506 | - if($value !== null && $value !== '') { |
|
506 | + if ($value !== null && $value !== '') { |
|
507 | 507 | return $value; |
508 | 508 | } |
509 | 509 | |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | { |
523 | 523 | $total = count($this->filters); |
524 | 524 | for ($i = 0; $i < $total; $i++) { |
525 | - $method = 'applyFilter_' . $this->filters[$i]['type']; |
|
525 | + $method = 'applyFilter_'.$this->filters[$i]['type']; |
|
526 | 526 | $value = $this->$method($value, $this->filters[$i]['params']); |
527 | 527 | } |
528 | 528 | |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
680 | 680 | * @return \AppUtils\Request_Param |
681 | 681 | */ |
682 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
|
682 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : Request_Param |
|
683 | 683 | { |
684 | 684 | $this->setArray(); |
685 | 685 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | ); |
693 | 693 | } |
694 | 694 | |
695 | - protected function addClassFilter(string $name, array $params=array()) : Request_Param |
|
695 | + protected function addClassFilter(string $name, array $params = array()) : Request_Param |
|
696 | 696 | { |
697 | 697 | return $this->addFilter( |
698 | 698 | self::FILTER_TYPE_CLASS, |