@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @throws ReflectionExceptionAlias |
48 | 48 | */ |
49 | - public function __construct($clientData=null) |
|
49 | + public function __construct($clientData = null) |
|
50 | 50 | { |
51 | 51 | //reflection process |
52 | 52 | $this->reflection = app()['reflection']($this); |
@@ -69,25 +69,25 @@ discard block |
||
69 | 69 | private function autoValidate($validate) |
70 | 70 | { |
71 | 71 | //we get the values to auto-validate. |
72 | - foreach ($this->{$validate} as $object=>$datas){ |
|
72 | + foreach ($this->{$validate} as $object=>$datas) { |
|
73 | 73 | |
74 | 74 | // the auto-validate value must necessarily represent a class. |
75 | 75 | // otherwise auto-validate is not used. |
76 | - if(Utils::isNamespaceExists($object)){ |
|
76 | + if (Utils::isNamespaceExists($object)) { |
|
77 | 77 | $getObjectInstance = app()->resolve($object); |
78 | 78 | |
79 | 79 | // we get the index values, |
80 | 80 | // which are called methods of the auto-validate value that represents the class. |
81 | - foreach ($datas as $dataKey=>$data){ |
|
81 | + foreach ($datas as $dataKey=>$data) { |
|
82 | 82 | |
83 | 83 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
84 | 84 | // the process of auto-validate automatic implementation will be completed. |
85 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){ |
|
86 | - if(isset($this->origin[$data])){ |
|
87 | - if(!is_array($this->origin[$data])){ |
|
85 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) { |
|
86 | + if (isset($this->origin[$data])) { |
|
87 | + if (!is_array($this->origin[$data])) { |
|
88 | 88 | $this->origin[$data] = array($this->origin[$data]); |
89 | 89 | } |
90 | - foreach ($this->origin[$data] as $originData){ |
|
90 | + foreach ($this->origin[$data] as $originData) { |
|
91 | 91 | $getObjectInstance->{$data}($originData); |
92 | 92 | } |
93 | 93 | } |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | |
110 | 110 | // Determines which HTTP method |
111 | 111 | // the request object will be exposed to. |
112 | - if($this->checkProperties('http')){ |
|
112 | + if ($this->checkProperties('http')) { |
|
113 | 113 | |
114 | 114 | // if the current http method does not exist |
115 | 115 | // in the http object, the exception will be thrown. |
116 | - if(!in_array($method,$this->http)){ |
|
116 | + if (!in_array($method, $this->http)) { |
|
117 | 117 | |
118 | 118 | //exception batMethodCall |
119 | 119 | exception()->badMethodCall( |
120 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
120 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | // from the properties of the object properties to |
134 | 134 | // the existing variables, control the array and at least one element. |
135 | - return (property_exists($this,$properties) |
|
135 | + return (property_exists($this, $properties) |
|
136 | 136 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
137 | 137 | } |
138 | 138 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | // we are saving the expected values for the request in container. |
147 | 147 | // this record can be returned in exception information. |
148 | - app()->register('requestExpected',$this->expected); |
|
148 | + app()->register('requestExpected', $this->expected); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | public function except($except) |
158 | 158 | { |
159 | 159 | // the except parameter is a callable value. |
160 | - if(is_callable($except)){ |
|
161 | - $call = call_user_func_array($except,[$this]); |
|
160 | + if (is_callable($except)) { |
|
161 | + $call = call_user_func_array($except, [$this]); |
|
162 | 162 | $except = $call; |
163 | 163 | } |
164 | 164 | |
165 | 165 | // except with the except exceptions property |
166 | 166 | // and then assigning them to the inputs property. |
167 | - $this->except = array_merge($this->except,$except); |
|
168 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
167 | + $this->except = array_merge($this->except, $except); |
|
168 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
169 | 169 | |
170 | 170 | return $this; |
171 | 171 | } |
@@ -179,27 +179,27 @@ discard block |
||
179 | 179 | { |
180 | 180 | // expected method is executed. |
181 | 181 | // this method is a must for http method values to be found in this property. |
182 | - if($this->checkProperties('expected')){ |
|
182 | + if ($this->checkProperties('expected')) { |
|
183 | 183 | |
184 | 184 | // if the expected values are not found in the inputs array, |
185 | 185 | // the exception will be thrown. |
186 | - foreach ($this->expected as $expected){ |
|
186 | + foreach ($this->expected as $expected) { |
|
187 | 187 | |
188 | 188 | $expectedValues = []; |
189 | 189 | |
190 | 190 | // mandatory expected data for each key can be separated by | operator. |
191 | 191 | // this is evaluated as "or". |
192 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
193 | - if(!isset($this->inputs[$inputs])){ |
|
192 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
193 | + if (!isset($this->inputs[$inputs])) { |
|
194 | 194 | $expectedValues[] = $inputs; |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | 198 | // if the expectedData and expectedValues |
199 | 199 | // array are numerically equal to the expected key, the exception is thrown. |
200 | - if(count($expectedData)===count($expectedValues)){ |
|
200 | + if (count($expectedData)===count($expectedValues)) { |
|
201 | 201 | exception($expected) |
202 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
202 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | { |
215 | 215 | // check the presence of the generator object |
216 | 216 | // and operate the generator over this object. |
217 | - if($this->checkProperties('auto_generators')){ |
|
217 | + if ($this->checkProperties('auto_generators')) { |
|
218 | 218 | $generators = $this->getAutoGenerators(); |
219 | 219 | } |
220 | 220 | |
221 | 221 | // check the presence of the generator object |
222 | 222 | // and operate the generator over this object. |
223 | - if($this->checkProperties('generators')){ |
|
224 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
223 | + if ($this->checkProperties('generators')) { |
|
224 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
225 | 225 | } |
226 | 226 | |
227 | - if(isset($generators)){ |
|
227 | + if (isset($generators)) { |
|
228 | 228 | $this->generatorMethod($generators); |
229 | 229 | } |
230 | 230 | } |
@@ -239,30 +239,30 @@ discard block |
||
239 | 239 | private function generatorMethod($generators) |
240 | 240 | { |
241 | 241 | //generator array object |
242 | - foreach ($generators as $generator){ |
|
242 | + foreach ($generators as $generator) { |
|
243 | 243 | |
244 | 244 | //generator method name |
245 | 245 | $generatorMethodName = $generator.'Generator'; |
246 | 246 | |
247 | 247 | // if the generator method is present, |
248 | 248 | // the fake value is assigned. |
249 | - if(method_exists($this,$generatorMethodName)){ |
|
249 | + if (method_exists($this, $generatorMethodName)) { |
|
250 | 250 | |
251 | 251 | //fake registration |
252 | - if(!isset($this->inputs[$generator])){ |
|
252 | + if (!isset($this->inputs[$generator])) { |
|
253 | 253 | $this->{$generator} = $this->{$generatorMethodName}(); |
254 | 254 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
255 | 255 | } |
256 | 256 | else { |
257 | 257 | |
258 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
259 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
258 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
259 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
260 | 260 | $this->{$generator} = $this->{$generatorMethodName}(); |
261 | 261 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
262 | 262 | } |
263 | 263 | |
264 | - if($this->checkProperties('generators_dont_overwrite') |
|
265 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
264 | + if ($this->checkProperties('generators_dont_overwrite') |
|
265 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
266 | 266 | $this->{$generator} = $this->{$generatorMethodName}(); |
267 | 267 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
268 | 268 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | { |
310 | 310 | // we use the http method to write |
311 | 311 | // the values to the inputs and origin properties. |
312 | - foreach($this->clientData as $key=>$value){ |
|
312 | + foreach ($this->clientData as $key=>$value) { |
|
313 | 313 | |
314 | 314 | //inputs and origin properties |
315 | 315 | $this->inputs[$key] = $value; |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | |
354 | 354 | // we update the input values after |
355 | 355 | // we receive and check the saved objects. |
356 | - foreach ($clientObjects as $key=>$value){ |
|
356 | + foreach ($clientObjects as $key=>$value) { |
|
357 | 357 | |
358 | - if(isset($clientObjects['origin'][$key])){ |
|
358 | + if (isset($clientObjects['origin'][$key])) { |
|
359 | 359 | |
360 | 360 | $this->{$key} = $clientObjects['origin'][$key]; |
361 | 361 | $this->inputs[$key] = $this->{$key}; |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | |
383 | 383 | // the request update to be performed using |
384 | 384 | // the method name to be used with the http method. |
385 | - $this->setRequestInputs($requestMethod,$key); |
|
385 | + $this->setRequestInputs($requestMethod, $key); |
|
386 | 386 | |
387 | 387 | // the request update to be performed using |
388 | 388 | // the method name to be used without the http method. |
389 | - $this->setRequestInputs($key,$key); |
|
389 | + $this->setRequestInputs($key, $key); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -397,28 +397,28 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @throws ReflectionExceptionAlias |
399 | 399 | */ |
400 | - private function setRequestInputs($method,$key) |
|
400 | + private function setRequestInputs($method, $key) |
|
401 | 401 | { |
402 | - if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
402 | + if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
403 | 403 | |
404 | 404 | //check annotations for method |
405 | - $annotation = app()->resolve(RequestAnnotationManager::class,['request'=>$this]); |
|
406 | - $annotation->annotation($method,$key); |
|
405 | + $annotation = app()->resolve(RequestAnnotationManager::class, ['request'=>$this]); |
|
406 | + $annotation->annotation($method, $key); |
|
407 | 407 | |
408 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
408 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
409 | 409 | |
410 | 410 | $inputKeys = $this->inputs[$key]; |
411 | 411 | |
412 | 412 | $this->inputs[$key] = []; |
413 | - foreach ($inputKeys as $input){ |
|
413 | + foreach ($inputKeys as $input) { |
|
414 | 414 | |
415 | 415 | $this->{$key} = $input; |
416 | 416 | $keyMethod = $this->{$method}(); |
417 | 417 | $this->inputs[$key][] = $keyMethod; |
418 | 418 | } |
419 | 419 | } |
420 | - else{ |
|
421 | - if(isset($this->inputs[$key])){ |
|
420 | + else { |
|
421 | + if (isset($this->inputs[$key])) { |
|
422 | 422 | $keyMethod = $this->{$method}(); |
423 | 423 | $this->inputs[$key] = $keyMethod; |
424 | 424 | } |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | { |
437 | 437 | // the auto object validate property is the property |
438 | 438 | // where all of your request values are automatically validated. |
439 | - if(property_exists($this,'autoObjectValidate') |
|
440 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
439 | + if (property_exists($this, 'autoObjectValidate') |
|
440 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
441 | 441 | $this->autoValidate('autoObjectValidate'); |
442 | 442 | } |
443 | 443 | } |