@@ -38,8 +38,9 @@ |
||
38 | 38 | { |
39 | 39 | foreach ($attributes as $name => $value) |
40 | 40 | { |
41 | - if (!is_string($name)) |
|
42 | - throw new \InvalidArgumentException("Attribute only accepts strings as names"); |
|
41 | + if (!is_string($name)) { |
|
42 | + throw new \InvalidArgumentException("Attribute only accepts strings as names"); |
|
43 | + } |
|
43 | 44 | |
44 | 45 | $instance->setAttribute(new Attribute($name, $value)); |
45 | 46 | } |
@@ -258,12 +258,12 @@ |
||
258 | 258 | { |
259 | 259 | if (static::HAS_END_TAG) |
260 | 260 | { |
261 | - $this->startTag = "<" .strtolower(static::NODE_NAME). ">"; |
|
262 | - $this->endTag = "</" .strtolower(static::NODE_NAME). ">"; |
|
261 | + $this->startTag = "<" . strtolower(static::NODE_NAME) . ">"; |
|
262 | + $this->endTag = "</" . strtolower(static::NODE_NAME) . ">"; |
|
263 | 263 | } |
264 | 264 | else |
265 | 265 | { |
266 | - $this->startTag = "<" .strtolower(static::NODE_NAME); |
|
266 | + $this->startTag = "<" . strtolower(static::NODE_NAME); |
|
267 | 267 | $this->endTag = "/>"; |
268 | 268 | } |
269 | 269 | } |
@@ -110,8 +110,9 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function hasChild($label) |
112 | 112 | { |
113 | - if (array_key_exists($label, $this->children)) |
|
114 | - return true; |
|
113 | + if (array_key_exists($label, $this->children)) { |
|
114 | + return true; |
|
115 | + } |
|
115 | 116 | |
116 | 117 | return false; |
117 | 118 | } |
@@ -125,8 +126,9 @@ discard block |
||
125 | 126 | */ |
126 | 127 | public function getChild($label) |
127 | 128 | { |
128 | - if (array_key_exists($label, $this->children)) |
|
129 | - return $this->children[$label]; |
|
129 | + if (array_key_exists($label, $this->children)) { |
|
130 | + return $this->children[$label]; |
|
131 | + } |
|
130 | 132 | |
131 | 133 | return null; |
132 | 134 | } |
@@ -155,10 +157,11 @@ discard block |
||
155 | 157 | */ |
156 | 158 | public function removeChild($label) |
157 | 159 | { |
158 | - if (array_key_exists($label, $this->children)) |
|
159 | - unset($this->children[$label]); |
|
160 | - else |
|
161 | - throw new Exception\ChildNotFoundException("The child to remove does not exists"); |
|
160 | + if (array_key_exists($label, $this->children)) { |
|
161 | + unset($this->children[$label]); |
|
162 | + } else { |
|
163 | + throw new Exception\ChildNotFoundException("The child to remove does not exists"); |
|
164 | + } |
|
162 | 165 | } |
163 | 166 | |
164 | 167 | /** |
@@ -174,8 +177,9 @@ discard block |
||
174 | 177 | { |
175 | 178 | foreach ($this->attributes as $attrib) |
176 | 179 | { |
177 | - if ($attrib->getName() == $name) |
|
178 | - return true; |
|
180 | + if ($attrib->getName() == $name) { |
|
181 | + return true; |
|
182 | + } |
|
179 | 183 | } |
180 | 184 | } |
181 | 185 | |
@@ -195,8 +199,9 @@ discard block |
||
195 | 199 | { |
196 | 200 | foreach ($this->attributes as $attrib) |
197 | 201 | { |
198 | - if ($attrib->getName() == $name) |
|
199 | - return $attrib; |
|
202 | + if ($attrib->getName() == $name) { |
|
203 | + return $attrib; |
|
204 | + } |
|
200 | 205 | } |
201 | 206 | } |
202 | 207 | |
@@ -218,12 +223,13 @@ discard block |
||
218 | 223 | { |
219 | 224 | foreach ($this->attributes as $key => $_attrib) |
220 | 225 | { |
221 | - if ($_attrib->getName() == $attrib->getName()) |
|
222 | - $this->attributes[$key] = $attribute; |
|
226 | + if ($_attrib->getName() == $attrib->getName()) { |
|
227 | + $this->attributes[$key] = $attribute; |
|
228 | + } |
|
223 | 229 | } |
230 | + } else { |
|
231 | + $this->attributes[] = $attribute; |
|
224 | 232 | } |
225 | - else |
|
226 | - $this->attributes[] = $attribute; |
|
227 | 233 | } |
228 | 234 | |
229 | 235 | /** |
@@ -241,8 +247,9 @@ discard block |
||
241 | 247 | { |
242 | 248 | foreach ($this->attributes as $key => $attrib) |
243 | 249 | { |
244 | - if ($attrib->getName() == $name) |
|
245 | - unset($this->attributes[$key]); |
|
250 | + if ($attrib->getName() == $name) { |
|
251 | + unset($this->attributes[$key]); |
|
252 | + } |
|
246 | 253 | } |
247 | 254 | } |
248 | 255 | |
@@ -260,8 +267,7 @@ discard block |
||
260 | 267 | { |
261 | 268 | $this->startTag = "<" .strtolower(static::NODE_NAME). ">"; |
262 | 269 | $this->endTag = "</" .strtolower(static::NODE_NAME). ">"; |
263 | - } |
|
264 | - else |
|
270 | + } else |
|
265 | 271 | { |
266 | 272 | $this->startTag = "<" .strtolower(static::NODE_NAME); |
267 | 273 | $this->endTag = "/>"; |
@@ -275,8 +281,9 @@ discard block |
||
275 | 281 | */ |
276 | 282 | public function isFormControl() |
277 | 283 | { |
278 | - if (in_array(static::NODE_NAME, ['INPUT'])) |
|
279 | - return true; |
|
284 | + if (in_array(static::NODE_NAME, ['INPUT'])) { |
|
285 | + return true; |
|
286 | + } |
|
280 | 287 | |
281 | 288 | return false; |
282 | 289 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | ]); |
48 | 48 | |
49 | 49 | $form->fill([ |
50 | - "username" => 'jobs', # wrong because of minlength attr |
|
50 | + "username" => 'jobs', # wrong because of minlength attr |
|
51 | 51 | "password" => 'jVi7Qp4X', |
52 | 52 | "email" => 'j@' # wrong because of type and minlength attr |
53 | 53 | ]); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | ]); |
199 | 199 | |
200 | 200 | $form->fill([ |
201 | - "username" => 'jobs', # wrong because of minlength attr |
|
201 | + "username" => 'jobs', # wrong because of minlength attr |
|
202 | 202 | ]); |
203 | 203 | |
204 | 204 | $validator = new FormValidator($form, 'en'); |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | $form->fill([ |
244 | 244 | "product" => [ |
245 | 245 | "optical mouse", |
246 | - "-", # wrong name |
|
246 | + "-", # wrong name |
|
247 | 247 | "78" # another wrong name |
248 | 248 | ], |
249 | 249 | "price" => [ |
250 | 250 | 10, |
251 | - 0, # wrong price |
|
251 | + 0, # wrong price |
|
252 | 252 | 0 # another wrong price |
253 | 253 | ] |
254 | 254 | ]); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ]); |
306 | 306 | |
307 | 307 | $form->fill([ |
308 | - "username" => 'steave jobs', # wrong because of minlength attr |
|
308 | + "username" => 'steave jobs', # wrong because of minlength attr |
|
309 | 309 | "password" => 'jVi7Qp4X', |
310 | 310 | "type" => 'moderator' # wrong because moderator is not a valid needle |
311 | 311 | ]); |
@@ -48,11 +48,13 @@ |
||
48 | 48 | { |
49 | 49 | $child = $this->getChild($label); |
50 | 50 | |
51 | - if (is_null($child)) |
|
52 | - throw new Exception\ChildNotFoundException("The child '$label' does not exists inside the form element"); |
|
51 | + if (is_null($child)) { |
|
52 | + throw new Exception\ChildNotFoundException("The child '$label' does not exists inside the form element"); |
|
53 | + } |
|
53 | 54 | |
54 | - if (!$child->isFormControl()) |
|
55 | - throw new Exception\NotFormControlException("The child '$label' is not a form control"); |
|
55 | + if (!$child->isFormControl()) { |
|
56 | + throw new Exception\NotFormControlException("The child '$label' is not a form control"); |
|
57 | + } |
|
56 | 58 | |
57 | 59 | $child->setAttribute(new Attribute("value", $value)); |
58 | 60 | } |
@@ -92,29 +92,32 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function _error($code, $message = null) |
94 | 94 | { |
95 | - if (!is_null($code) && !is_integer($code) && !is_string($code)) |
|
96 | - throw new \InvalidArgumentException("Invalid type given. Integer or string expected"); |
|
95 | + if (!is_null($code) && !is_integer($code) && !is_string($code)) { |
|
96 | + throw new \InvalidArgumentException("Invalid type given. Integer or string expected"); |
|
97 | + } |
|
97 | 98 | |
98 | - if (is_null($code)) |
|
99 | - $code = preg_replace('/=|\/|\+/', "", base64_encode($message)); |
|
100 | - else |
|
99 | + if (is_null($code)) { |
|
100 | + $code = preg_replace('/=|\/|\+/', "", base64_encode($message)); |
|
101 | + } else |
|
101 | 102 | { |
102 | - if (!array_key_exists($code, $this->standardErrors) && empty($message)) |
|
103 | - /* |
|
103 | + if (!array_key_exists($code, $this->standardErrors) && empty($message)) { |
|
104 | + /* |
|
104 | 105 | * Non-standard errors must have a message to describe the error, make sure |
105 | 106 | * you execute the error() method with a message as the second parameter. |
106 | 107 | */ |
107 | 108 | throw new \LogicException('The message does not be empty in non-standard errors!'); |
109 | + } |
|
108 | 110 | } |
109 | 111 | |
110 | - if (!array_key_exists($code, $this->errors)) |
|
111 | - $this->errors[$code] = (array_key_exists($code, $this->standardErrors)) |
|
112 | + if (!array_key_exists($code, $this->errors)) { |
|
113 | + $this->errors[$code] = (array_key_exists($code, $this->standardErrors)) |
|
112 | 114 | ? |
113 | 115 | is_null($message) |
114 | 116 | ? preg_replace('/\s\'%[a-zA-Z]*%\'/', $message, $this->standardErrors[$code]) |
115 | 117 | # if $message is not null it will replace the %file% wildcard |
116 | 118 | : preg_replace('/%[a-zA-Z]*%/', $message, $this->standardErrors[$code]) |
117 | 119 | : $message; |
120 | + } |
|
118 | 121 | } |
119 | 122 | |
120 | 123 | function __call($method, $arguments) |
@@ -124,10 +127,11 @@ discard block |
||
124 | 127 | switch (count($arguments)) |
125 | 128 | { |
126 | 129 | case 1: |
127 | - if (is_integer($arguments[0])) |
|
128 | - return call_user_func([$this, '_error'], array_shift($arguments)); |
|
129 | - else |
|
130 | - return call_user_func([$this, '_error'], null, array_shift($arguments)); |
|
130 | + if (is_integer($arguments[0])) { |
|
131 | + return call_user_func([$this, '_error'], array_shift($arguments)); |
|
132 | + } else { |
|
133 | + return call_user_func([$this, '_error'], null, array_shift($arguments)); |
|
134 | + } |
|
131 | 135 | break; |
132 | 136 | case 2: |
133 | 137 | return call_user_func([$this, '_error'], $arguments[0], $arguments[1]); |
@@ -304,7 +304,7 @@ |
||
304 | 304 | { |
305 | 305 | foreach ($validator->getMessages() as $message) |
306 | 306 | { |
307 | - $this->error($label ."-~-". (count($this->getErrors()) + 1), $message); |
|
307 | + $this->error($label . "-~-" . (count($this->getErrors()) + 1), $message); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | } |
@@ -69,9 +69,10 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function isValid() |
71 | 71 | { |
72 | - if (is_null($this->valid)) |
|
73 | - # This error is thrown because of 'setValid' method has not been executed. |
|
72 | + if (is_null($this->valid)) { |
|
73 | + # This error is thrown because of 'setValid' method has not been executed. |
|
74 | 74 | throw new \LogicException('No validation has been executed!'); |
75 | + } |
|
75 | 76 | |
76 | 77 | return $this->valid; |
77 | 78 | } |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | { |
99 | 100 | $this->form = $form; |
100 | 101 | |
101 | - if (is_null($locale)) |
|
102 | - $locale = 'en'; |
|
102 | + if (is_null($locale)) { |
|
103 | + $locale = 'en'; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $i18nTranslator = \Zend\I18n\Translator\Translator::factory( |
105 | 107 | [ |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | |
134 | 136 | foreach ($elements as $label => $element) |
135 | 137 | { |
136 | - if (!$element->isFormControl()) |
|
137 | - continue; |
|
138 | + if (!$element->isFormControl()) { |
|
139 | + continue; |
|
140 | + } |
|
138 | 141 | |
139 | 142 | $attribs = $element->getAttributes(); |
140 | 143 | |
@@ -203,19 +206,21 @@ discard block |
||
203 | 206 | |
204 | 207 | case 'min': |
205 | 208 | |
206 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) |
|
207 | - $validator = new GreaterThan(['min' => $value, 'inclusive' => true]); |
|
208 | - else |
|
209 | - throw new \LogicException("The input type must be 'range' or 'number'"); |
|
209 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) { |
|
210 | + $validator = new GreaterThan(['min' => $value, 'inclusive' => true]); |
|
211 | + } else { |
|
212 | + throw new \LogicException("The input type must be 'range' or 'number'"); |
|
213 | + } |
|
210 | 214 | |
211 | 215 | break; |
212 | 216 | |
213 | 217 | case 'max': |
214 | 218 | |
215 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) |
|
216 | - $validator = new LessThan(['max' => $value, 'inclusive' => true]); |
|
217 | - else |
|
218 | - throw new \LogicException("The input type must be 'range' or 'number'"); |
|
219 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) { |
|
220 | + $validator = new LessThan(['max' => $value, 'inclusive' => true]); |
|
221 | + } else { |
|
222 | + throw new \LogicException("The input type must be 'range' or 'number'"); |
|
223 | + } |
|
219 | 224 | |
220 | 225 | break; |
221 | 226 | |
@@ -223,17 +228,19 @@ discard block |
||
223 | 228 | |
224 | 229 | $baseValue = (array_key_exists('min', $all_attribs)) ? $all_attribs['min'] : 0; |
225 | 230 | |
226 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) |
|
227 | - $validator = new Step(['baseValue' => $baseValue, 'step' => $value]); |
|
228 | - else |
|
229 | - throw new \LogicException("The input type must be 'range'"); |
|
231 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) { |
|
232 | + $validator = new Step(['baseValue' => $baseValue, 'step' => $value]); |
|
233 | + } else { |
|
234 | + throw new \LogicException("The input type must be 'range'"); |
|
235 | + } |
|
230 | 236 | |
231 | 237 | break; |
232 | 238 | |
233 | 239 | case 'data-validators': |
234 | 240 | |
235 | - if (!is_array($value)) |
|
236 | - throw new \InvalidArgumentException("Invalid type given. Array expected in 'data-validators' attribute."); |
|
241 | + if (!is_array($value)) { |
|
242 | + throw new \InvalidArgumentException("Invalid type given. Array expected in 'data-validators' attribute."); |
|
243 | + } |
|
237 | 244 | |
238 | 245 | foreach ($value as $class => $params) |
239 | 246 | { |
@@ -243,8 +250,9 @@ discard block |
||
243 | 250 | { |
244 | 251 | $className = "\Zend\I18n\Validator\\" . $class; |
245 | 252 | |
246 | - if (!class_exists($className)) |
|
247 | - throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists"); |
|
253 | + if (!class_exists($className)) { |
|
254 | + throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists"); |
|
255 | + } |
|
248 | 256 | } |
249 | 257 | |
250 | 258 | $validator = new $className($params); |
@@ -291,8 +299,9 @@ discard block |
||
291 | 299 | $v->setTranslator($this->translator); |
292 | 300 | $notEmpty = $v->isValid($val); |
293 | 301 | |
294 | - if (!$required && !$notEmpty) |
|
295 | - return null; |
|
302 | + if (!$required && !$notEmpty) { |
|
303 | + return null; |
|
304 | + } |
|
296 | 305 | |
297 | 306 | $valid = $validator->isValid($val); |
298 | 307 | $this->setValid($valid); |
@@ -304,8 +313,7 @@ discard block |
||
304 | 313 | $this->error($label ."-~-". (count($this->getErrors()) + 1), $message); |
305 | 314 | } |
306 | 315 | } |
307 | - } |
|
308 | - else |
|
316 | + } else |
|
309 | 317 | { |
310 | 318 | foreach ($form_value as $val) |
311 | 319 | { |
@@ -330,8 +338,9 @@ discard block |
||
330 | 338 | $errorLbl = explode("-~-", $key); |
331 | 339 | $label = array_shift($errorLbl); |
332 | 340 | |
333 | - if (!array_key_exists($label, $errors)) |
|
334 | - $errors[$label] = []; |
|
341 | + if (!array_key_exists($label, $errors)) { |
|
342 | + $errors[$label] = []; |
|
343 | + } |
|
335 | 344 | |
336 | 345 | $errors[$label][] = $value; |
337 | 346 | } |
@@ -93,7 +93,7 @@ |
||
93 | 93 | { |
94 | 94 | $new = array(); |
95 | 95 | |
96 | - foreach($obj as $key => $val) |
|
96 | + foreach ($obj as $key => $val) |
|
97 | 97 | { |
98 | 98 | $new[$key] = self::objectToArray($val); |
99 | 99 | } |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $again = true; |
40 | 40 | $new_config[$param . $glue . $key] = $value; |
41 | 41 | } |
42 | + } else { |
|
43 | + $new_config[$param] = $configure; |
|
42 | 44 | } |
43 | - else |
|
44 | - $new_config[$param] = $configure; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return (!$again) ? $new_config : self::toUnidimensional($new_config, $glue); |
@@ -64,15 +64,17 @@ discard block |
||
64 | 64 | |
65 | 65 | do |
66 | 66 | { |
67 | - if (array_key_exists($key, $haystack)) |
|
68 | - $haystack = $haystack[$key]; |
|
69 | - else |
|
70 | - return $value; |
|
67 | + if (array_key_exists($key, $haystack)) { |
|
68 | + $haystack = $haystack[$key]; |
|
69 | + } else { |
|
70 | + return $value; |
|
71 | + } |
|
71 | 72 | |
72 | 73 | $key = count($needle) ? array_shift($needle) : NULL; |
73 | 74 | |
74 | - if (is_null($key)) |
|
75 | - return $haystack; |
|
75 | + if (is_null($key)) { |
|
76 | + return $haystack; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | } while (!is_null($key)); |
78 | 80 | } |
@@ -86,8 +88,9 @@ discard block |
||
86 | 88 | */ |
87 | 89 | public static function objectToArray($obj) |
88 | 90 | { |
89 | - if (is_object($obj)) |
|
90 | - $obj = (array) $obj; |
|
91 | + if (is_object($obj)) { |
|
92 | + $obj = (array) $obj; |
|
93 | + } |
|
91 | 94 | |
92 | 95 | if (is_array($obj)) |
93 | 96 | { |
@@ -97,9 +100,9 @@ discard block |
||
97 | 100 | { |
98 | 101 | $new[$key] = self::objectToArray($val); |
99 | 102 | } |
103 | + } else { |
|
104 | + $new = $obj; |
|
100 | 105 | } |
101 | - else |
|
102 | - $new = $obj; |
|
103 | 106 | |
104 | 107 | return $new; |
105 | 108 | } |
@@ -25,8 +25,7 @@ discard block |
||
25 | 25 | try |
26 | 26 | { |
27 | 27 | throw new ExceptionException("This is an storable exception"); |
28 | - } |
|
29 | - catch (ExceptionException $e) |
|
28 | + } catch (ExceptionException $e) |
|
30 | 29 | { |
31 | 30 | mkdir('exceptions'); |
32 | 31 | |
@@ -64,8 +63,7 @@ discard block |
||
64 | 63 | try |
65 | 64 | { |
66 | 65 | throw new ExceptionException("This is an storable exception too"); |
67 | - } |
|
68 | - catch (ExceptionException $e) |
|
66 | + } catch (ExceptionException $e) |
|
69 | 67 | { |
70 | 68 | $date = date('dmY'); |
71 | 69 | $file = 'nofolder/exception-' . $date . '.json'; |
@@ -95,8 +93,7 @@ discard block |
||
95 | 93 | try |
96 | 94 | { |
97 | 95 | throw new ExceptionException("This is an storable exception"); |
98 | - } |
|
99 | - catch (ExceptionException $e) |
|
96 | + } catch (ExceptionException $e) |
|
100 | 97 | { |
101 | 98 | $file = 'exceptions/exception-' . $date . '.json'; |
102 | 99 | $storage = new \Drone\Exception\Storage($file); |
@@ -106,8 +103,7 @@ discard block |
||
106 | 103 | try |
107 | 104 | { |
108 | 105 | throw new ExceptionException("This is an storable exception too"); |
109 | - } |
|
110 | - catch (ExceptionException $e) |
|
106 | + } catch (ExceptionException $e) |
|
111 | 107 | { |
112 | 108 | $file = 'exceptions/exception-' . $date . '.json'; |
113 | 109 | $storage = new \Drone\Exception\Storage($file); |
@@ -313,7 +313,7 @@ |
||
313 | 313 | if ($_SERVER['REQUEST_METHOD'] != 'JSON') |
314 | 314 | throw new \LogicException("Request method is not JSON"); |
315 | 315 | |
316 | - $input = file_get_contents('php://input'); |
|
316 | + $input = file_get_contents('php://input'); |
|
317 | 317 | $array = explode("&", $input); |
318 | 318 | |
319 | 319 | $result = []; |
@@ -86,13 +86,14 @@ discard block |
||
86 | 86 | { |
87 | 87 | $method = $this->method; |
88 | 88 | |
89 | - if (is_null($method)) |
|
90 | - # This error is thrown because of 'setMethod' method has not been executed |
|
89 | + if (is_null($method)) { |
|
90 | + # This error is thrown because of 'setMethod' method has not been executed |
|
91 | 91 | throw new \LogicException("No method has been setted to execute!"); |
92 | + } |
|
92 | 93 | |
93 | - if (!is_null($this->module) && !$this->module->executionIsAllowed()) |
|
94 | - throw new Exception\MethodExecutionNotAllowedException("Method execution is not allowed"); |
|
95 | - else |
|
94 | + if (!is_null($this->module) && !$this->module->executionIsAllowed()) { |
|
95 | + throw new Exception\MethodExecutionNotAllowedException("Method execution is not allowed"); |
|
96 | + } else |
|
96 | 97 | { |
97 | 98 | if (method_exists($this, $method)) |
98 | 99 | { |
@@ -100,12 +101,12 @@ discard block |
||
100 | 101 | |
101 | 102 | $reflection = new \ReflectionMethod($this, $method); |
102 | 103 | |
103 | - if (!$reflection->isPublic()) |
|
104 | - throw new Exception\PrivateMethodExecutionException("The method '$method' is not public in the control class '$class'"); |
|
104 | + if (!$reflection->isPublic()) { |
|
105 | + throw new Exception\PrivateMethodExecutionException("The method '$method' is not public in the control class '$class'"); |
|
106 | + } |
|
105 | 107 | |
106 | 108 | return $this->$method(); |
107 | - } |
|
108 | - else |
|
109 | + } else |
|
109 | 110 | { |
110 | 111 | $class = __CLASS__; |
111 | 112 | throw new Exception\MethodNotFoundException("The method '$method' doesn't exists in the control class '$class'"); |
@@ -130,8 +131,9 @@ discard block |
||
130 | 131 | */ |
131 | 132 | public function getPost() |
132 | 133 | { |
133 | - if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST)) |
|
134 | - $_POST = json_decode(file_get_contents('php://input'), true); |
|
134 | + if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST)) { |
|
135 | + $_POST = json_decode(file_get_contents('php://input'), true); |
|
136 | + } |
|
135 | 137 | |
136 | 138 | return (array) $_POST; |
137 | 139 | } |
@@ -145,8 +147,9 @@ discard block |
||
145 | 147 | */ |
146 | 148 | public function getJson() |
147 | 149 | { |
148 | - if ($_SERVER['REQUEST_METHOD'] != 'JSON') |
|
149 | - throw new \LogicException("Request method is not JSON"); |
|
150 | + if ($_SERVER['REQUEST_METHOD'] != 'JSON') { |
|
151 | + throw new \LogicException("Request method is not JSON"); |
|
152 | + } |
|
150 | 153 | |
151 | 154 | $input = file_get_contents('php://input'); |
152 | 155 | $array = explode("&", $input); |
@@ -170,8 +173,9 @@ discard block |
||
170 | 173 | public function isXmlHttpRequest() |
171 | 174 | { |
172 | 175 | # non standard (HTTP_X_REQUESTED_WITH is not a part of PHP) |
173 | - if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) |
|
174 | - return true; |
|
176 | + if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
|
177 | + return true; |
|
178 | + } |
|
175 | 179 | return false; |
176 | 180 | } |
177 | 181 | |
@@ -182,8 +186,9 @@ discard block |
||
182 | 186 | */ |
183 | 187 | public function isPost() |
184 | 188 | { |
185 | - if ($_SERVER["REQUEST_METHOD"] == "POST") |
|
186 | - return true; |
|
189 | + if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|
190 | + return true; |
|
191 | + } |
|
187 | 192 | return false; |
188 | 193 | } |
189 | 194 | |
@@ -194,8 +199,9 @@ discard block |
||
194 | 199 | */ |
195 | 200 | public function isGet() |
196 | 201 | { |
197 | - if ($_SERVER["REQUEST_METHOD"] == "GET") |
|
198 | - return true; |
|
202 | + if ($_SERVER["REQUEST_METHOD"] == "GET") { |
|
203 | + return true; |
|
204 | + } |
|
199 | 205 | return false; |
200 | 206 | } |
201 | 207 | } |
202 | 208 | \ No newline at end of file |