@@ -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.', |
@@ -159,22 +159,22 @@ discard block |
||
159 | 159 | // first off, apply filtering |
160 | 160 | $value = $this->filter($value); |
161 | 161 | |
162 | - if($this->valueType === self::VALUE_TYPE_LIST) |
|
162 | + if ($this->valueType === self::VALUE_TYPE_LIST) |
|
163 | 163 | { |
164 | - if(!is_array($value)) |
|
164 | + if (!is_array($value)) |
|
165 | 165 | { |
166 | 166 | $value = explode(',', $value); |
167 | 167 | } |
168 | 168 | |
169 | 169 | $keep = array(); |
170 | 170 | |
171 | - foreach($value as $subval) |
|
171 | + foreach ($value as $subval) |
|
172 | 172 | { |
173 | 173 | $subval = $this->filter($subval); |
174 | 174 | |
175 | 175 | $subval = $this->applyValidations($subval, true); |
176 | 176 | |
177 | - if($subval !== null) { |
|
177 | + if ($subval !== null) { |
|
178 | 178 | $keep[] = $subval; |
179 | 179 | } |
180 | 180 | } |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @param mixed $value |
196 | 196 | * @return mixed |
197 | 197 | */ |
198 | - protected function applyValidations($value, bool $subval=false) |
|
198 | + protected function applyValidations($value, bool $subval = false) |
|
199 | 199 | { |
200 | 200 | // go through all enqueued validations in turn, each time |
201 | 201 | // replacing the value with the adjusted, validated value. |
202 | - foreach($this->validations as $validateDef) |
|
202 | + foreach ($this->validations as $validateDef) |
|
203 | 203 | { |
204 | 204 | $value = $this->validateType($value, $validateDef['type'], $validateDef['params'], $subval); |
205 | 205 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | { |
223 | 223 | $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type); |
224 | 224 | |
225 | - if(!class_exists($class)) |
|
225 | + if (!class_exists($class)) |
|
226 | 226 | { |
227 | 227 | throw new Request_Exception( |
228 | 228 | 'Unknown validation type.', |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | { |
377 | 377 | $args = func_get_args(); // cannot be used as function parameter in some PHP versions |
378 | 378 | |
379 | - if(is_array($args[0])) |
|
379 | + if (is_array($args[0])) |
|
380 | 380 | { |
381 | 381 | $args = $args[0]; |
382 | 382 | } |
@@ -521,10 +521,10 @@ discard block |
||
521 | 521 | * @param mixed $default |
522 | 522 | * @return mixed |
523 | 523 | */ |
524 | - public function get($default=null) |
|
524 | + public function get($default = null) |
|
525 | 525 | { |
526 | 526 | $value = $this->request->getParam($this->paramName); |
527 | - if($value !== null && $value !== '') { |
|
527 | + if ($value !== null && $value !== '') { |
|
528 | 528 | return $value; |
529 | 529 | } |
530 | 530 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | { |
544 | 544 | $total = count($this->filters); |
545 | 545 | for ($i = 0; $i < $total; $i++) { |
546 | - $method = 'applyFilter_' . $this->filters[$i]['type']; |
|
546 | + $method = 'applyFilter_'.$this->filters[$i]['type']; |
|
547 | 547 | $value = $this->$method($value, $this->filters[$i]['params']); |
548 | 548 | } |
549 | 549 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
701 | 701 | * @return \AppUtils\Request_Param |
702 | 702 | */ |
703 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
|
703 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : Request_Param |
|
704 | 704 | { |
705 | 705 | $this->setArray(); |
706 | 706 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | ); |
714 | 714 | } |
715 | 715 | |
716 | - protected function addClassFilter(string $name, array $params=array()) : Request_Param |
|
716 | + protected function addClassFilter(string $name, array $params = array()) : Request_Param |
|
717 | 717 | { |
718 | 718 | return $this->addFilter( |
719 | 719 | self::FILTER_TYPE_CLASS, |
@@ -28,11 +28,11 @@ |
||
28 | 28 | protected function _validate() |
29 | 29 | { |
30 | 30 | // subvalues cannot be arrays |
31 | - if($this->isSubvalue) { |
|
31 | + if ($this->isSubvalue) { |
|
32 | 32 | return $this->value; |
33 | 33 | } |
34 | 34 | |
35 | - if(is_array($this->value)) { |
|
35 | + if (is_array($this->value)) { |
|
36 | 36 | return $this->value; |
37 | 37 | } |
38 | 38 |
@@ -33,22 +33,22 @@ |
||
33 | 33 | |
34 | 34 | // if we are validating a subvalue, it means we are |
35 | 35 | // validating a single value in the existing list. |
36 | - if($this->isSubvalue) |
|
36 | + if ($this->isSubvalue) |
|
37 | 37 | { |
38 | - if(in_array($this->value, $allowed)) { |
|
38 | + if (in_array($this->value, $allowed)) { |
|
39 | 39 | return $this->value; |
40 | 40 | } |
41 | 41 | |
42 | 42 | return null; |
43 | 43 | } |
44 | 44 | |
45 | - if(!is_array($this->value)) { |
|
45 | + if (!is_array($this->value)) { |
|
46 | 46 | return array(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | $keep = array(); |
50 | - foreach($this->value as $item) { |
|
51 | - if(in_array($item, $allowed)) { |
|
50 | + foreach ($this->value as $item) { |
|
51 | + if (in_array($item, $allowed)) { |
|
52 | 52 | $keep[] = $item; |
53 | 53 | } |
54 | 54 | } |