@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @throws ReflectionExceptionAlias |
58 | 58 | */ |
59 | - public function __construct($clientData=null) |
|
59 | + public function __construct($clientData = null) |
|
60 | 60 | { |
61 | 61 | //reflection process |
62 | 62 | $this->reflection = app()['reflection']($this); |
@@ -79,25 +79,25 @@ discard block |
||
79 | 79 | private function autoValidate($validate) |
80 | 80 | { |
81 | 81 | //we get the values to auto-validate. |
82 | - foreach ($this->{$validate} as $object=>$datas){ |
|
82 | + foreach ($this->{$validate} as $object=>$datas) { |
|
83 | 83 | |
84 | 84 | // the auto-validate value must necessarily represent a class. |
85 | 85 | // otherwise auto-validate is not used. |
86 | - if(Utils::isNamespaceExists($object)){ |
|
86 | + if (Utils::isNamespaceExists($object)) { |
|
87 | 87 | $getObjectInstance = app()->resolve($object); |
88 | 88 | |
89 | 89 | // we get the index values, |
90 | 90 | // which are called methods of the auto-validate value that represents the class. |
91 | - foreach ($datas as $dataKey=>$data){ |
|
91 | + foreach ($datas as $dataKey=>$data) { |
|
92 | 92 | |
93 | 93 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
94 | 94 | // the process of auto-validate automatic implementation will be completed. |
95 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){ |
|
96 | - if(isset($this->origin[$data])){ |
|
97 | - if(!is_array($this->origin[$data])){ |
|
95 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) { |
|
96 | + if (isset($this->origin[$data])) { |
|
97 | + if (!is_array($this->origin[$data])) { |
|
98 | 98 | $this->origin[$data] = array($this->origin[$data]); |
99 | 99 | } |
100 | - foreach ($this->origin[$data] as $originData){ |
|
100 | + foreach ($this->origin[$data] as $originData) { |
|
101 | 101 | $getObjectInstance->{$data}($originData); |
102 | 102 | } |
103 | 103 | } |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | { |
117 | 117 | // expected method is executed. |
118 | 118 | // this method is a must for http method values to be found in this property. |
119 | - if($this->checkProperties('capsule')){ |
|
119 | + if ($this->checkProperties('capsule')) { |
|
120 | 120 | |
121 | - if(property_exists($this,'auto_capsule') && is_array($this->auto_capsule)){ |
|
122 | - $this->capsule = array_merge($this->capsule,$this->auto_capsule); |
|
121 | + if (property_exists($this, 'auto_capsule') && is_array($this->auto_capsule)) { |
|
122 | + $this->capsule = array_merge($this->capsule, $this->auto_capsule); |
|
123 | 123 | } |
124 | 124 | $caret = $this->capsuleCaret(); |
125 | 125 | |
126 | - foreach($this->inputs as $input=>$value){ |
|
126 | + foreach ($this->inputs as $input=>$value) { |
|
127 | 127 | |
128 | - if(isset($caret[$input]) || ( |
|
129 | - $this->checkProperties('capsule') && !in_array($input,$this->capsule) |
|
130 | - )){ |
|
131 | - exception('clientCapsule',['key'=>$input]) |
|
128 | + if (isset($caret[$input]) || ( |
|
129 | + $this->checkProperties('capsule') && !in_array($input, $this->capsule) |
|
130 | + )) { |
|
131 | + exception('clientCapsule', ['key'=>$input]) |
|
132 | 132 | ->overflow('The '.$input.' value cannot be sent.'); |
133 | 133 | } |
134 | 134 | } |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | { |
145 | 145 | $caret = []; |
146 | 146 | |
147 | - foreach($this->inputs as $input=>$item){ |
|
148 | - if(in_array('@'.$input,$this->capsule)){ |
|
147 | + foreach ($this->inputs as $input=>$item) { |
|
148 | + if (in_array('@'.$input, $this->capsule)) { |
|
149 | 149 | $caret[$input] = $item; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | foreach ($this->capsule as $item) { |
154 | - if(preg_match('#@.*#is',$item)){ |
|
155 | - $this->capsule = array_diff($this->capsule,[$item]); |
|
154 | + if (preg_match('#@.*#is', $item)) { |
|
155 | + $this->capsule = array_diff($this->capsule, [$item]); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | |
172 | 172 | // Determines which HTTP method |
173 | 173 | // the request object will be exposed to. |
174 | - if($this->checkProperties('http')){ |
|
174 | + if ($this->checkProperties('http')) { |
|
175 | 175 | |
176 | 176 | // if the current http method does not exist |
177 | 177 | // in the http object, the exception will be thrown. |
178 | - if(!in_array($method,$this->http)){ |
|
178 | + if (!in_array($method, $this->http)) { |
|
179 | 179 | |
180 | 180 | //exception batMethodCall |
181 | 181 | exception()->badMethodCall( |
182 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
182 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | { |
195 | 195 | // from the properties of the object properties to |
196 | 196 | // the existing variables, control the array and at least one element. |
197 | - return (property_exists($this,$properties) |
|
197 | + return (property_exists($this, $properties) |
|
198 | 198 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
199 | 199 | } |
200 | 200 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | { |
208 | 208 | // we are saving the expected values for the request in container. |
209 | 209 | // this record can be returned in exception information. |
210 | - app()->register('requestExpected',$this->expected); |
|
210 | + app()->register('requestExpected', $this->expected); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | public function except($except) |
220 | 220 | { |
221 | 221 | // the except parameter is a callable value. |
222 | - if(is_callable($except)){ |
|
223 | - $call = call_user_func_array($except,[$this]); |
|
222 | + if (is_callable($except)) { |
|
223 | + $call = call_user_func_array($except, [$this]); |
|
224 | 224 | $except = $call; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // except with the except exceptions property |
228 | 228 | // and then assigning them to the inputs property. |
229 | - $this->except = array_merge($this->except,$except); |
|
230 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
229 | + $this->except = array_merge($this->except, $except); |
|
230 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
231 | 231 | |
232 | 232 | return $this; |
233 | 233 | } |
@@ -241,27 +241,27 @@ discard block |
||
241 | 241 | { |
242 | 242 | // expected method is executed. |
243 | 243 | // this method is a must for http method values to be found in this property. |
244 | - if($this->checkProperties('expected')){ |
|
244 | + if ($this->checkProperties('expected')) { |
|
245 | 245 | |
246 | 246 | // if the expected values are not found in the inputs array, |
247 | 247 | // the exception will be thrown. |
248 | - foreach ($this->expected as $expected){ |
|
248 | + foreach ($this->expected as $expected) { |
|
249 | 249 | |
250 | 250 | $expectedValues = []; |
251 | 251 | |
252 | 252 | // mandatory expected data for each key can be separated by | operator. |
253 | 253 | // this is evaluated as "or". |
254 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
255 | - if(!isset($this->inputs[$inputs])){ |
|
254 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
255 | + if (!isset($this->inputs[$inputs])) { |
|
256 | 256 | $expectedValues[] = $inputs; |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | // if the expectedData and expectedValues |
261 | 261 | // array are numerically equal to the expected key, the exception is thrown. |
262 | - if(count($expectedData)===count($expectedValues)){ |
|
263 | - exception('clientExpected',['key'=>$expected]) |
|
264 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
262 | + if (count($expectedData)===count($expectedValues)) { |
|
263 | + exception('clientExpected', ['key'=>$expected]) |
|
264 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | } |
@@ -276,17 +276,17 @@ discard block |
||
276 | 276 | { |
277 | 277 | // check the presence of the generator object |
278 | 278 | // and operate the generator over this object. |
279 | - if($this->checkProperties('auto_generators')){ |
|
279 | + if ($this->checkProperties('auto_generators')) { |
|
280 | 280 | $generators = $this->getAutoGenerators(); |
281 | 281 | } |
282 | 282 | |
283 | 283 | // check the presence of the generator object |
284 | 284 | // and operate the generator over this object. |
285 | - if($this->checkProperties('generators')){ |
|
286 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
285 | + if ($this->checkProperties('generators')) { |
|
286 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
287 | 287 | } |
288 | 288 | |
289 | - if(isset($generators)){ |
|
289 | + if (isset($generators)) { |
|
290 | 290 | $this->generatorMethod($generators); |
291 | 291 | } |
292 | 292 | } |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | private function generatorMethod($generators) |
302 | 302 | { |
303 | 303 | //generator array object |
304 | - foreach ($generators as $generator){ |
|
304 | + foreach ($generators as $generator) { |
|
305 | 305 | |
306 | 306 | //generator method name |
307 | 307 | $generatorMethodName = $generator.'Generator'; |
308 | 308 | |
309 | 309 | // if the generator method is present, |
310 | 310 | // the fake value is assigned. |
311 | - if(method_exists($this,$generatorMethodName)){ |
|
311 | + if (method_exists($this, $generatorMethodName)) { |
|
312 | 312 | |
313 | 313 | //fake registration |
314 | - if(!isset($this->inputs[$generator])){ |
|
314 | + if (!isset($this->inputs[$generator])) { |
|
315 | 315 | |
316 | 316 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
317 | 317 | |
318 | - if(!is_null($generatorMethodNameResult)){ |
|
318 | + if (!is_null($generatorMethodNameResult)) { |
|
319 | 319 | $this->{$generator} = $this->{$generatorMethodName}(); |
320 | 320 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
321 | 321 | $this->generatorList[] = $generator; |
@@ -323,15 +323,15 @@ discard block |
||
323 | 323 | } |
324 | 324 | else { |
325 | 325 | |
326 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
327 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
326 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
327 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
328 | 328 | $this->{$generator} = $this->{$generatorMethodName}(); |
329 | 329 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
330 | 330 | $this->generatorList[] = $generator; |
331 | 331 | } |
332 | 332 | |
333 | - if($this->checkProperties('generators_dont_overwrite') |
|
334 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
333 | + if ($this->checkProperties('generators_dont_overwrite') |
|
334 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
335 | 335 | $this->{$generator} = $this->{$generatorMethodName}(); |
336 | 336 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
337 | 337 | $this->generatorList[] = $generator; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | { |
385 | 385 | // we use the http method to write |
386 | 386 | // the values to the inputs and origin properties. |
387 | - foreach($this->clientData as $key=>$value){ |
|
387 | + foreach ($this->clientData as $key=>$value) { |
|
388 | 388 | |
389 | 389 | //inputs and origin properties |
390 | 390 | $this->inputs[$key] = $value; |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | */ |
401 | 401 | private function requestExcept() |
402 | 402 | { |
403 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
404 | - foreach ($this->requestExcept as $item){ |
|
405 | - if(isset($this->inputs[$item])){ |
|
403 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
404 | + foreach ($this->requestExcept as $item) { |
|
405 | + if (isset($this->inputs[$item])) { |
|
406 | 406 | unset($this->inputs[$item]); |
407 | 407 | } |
408 | 408 | } |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | |
448 | 448 | // we update the input values after |
449 | 449 | // we receive and check the saved objects. |
450 | - foreach ($clientObjects as $key=>$value){ |
|
450 | + foreach ($clientObjects as $key=>$value) { |
|
451 | 451 | |
452 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
452 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
453 | 453 | |
454 | 454 | $this->{$key} = $clientObjects['origin'][$key]; |
455 | 455 | $this->inputs[$key] = $this->{$key}; |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | |
478 | 478 | // the request update to be performed using |
479 | 479 | // the method name to be used with the http method. |
480 | - $this->setRequestInputs($requestMethod,$key); |
|
480 | + $this->setRequestInputs($requestMethod, $key); |
|
481 | 481 | |
482 | 482 | // the request update to be performed using |
483 | 483 | // the method name to be used without the http method. |
484 | - $this->setRequestInputs($key,$key); |
|
484 | + $this->setRequestInputs($key, $key); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -492,28 +492,28 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @throws ReflectionExceptionAlias |
494 | 494 | */ |
495 | - private function setRequestInputs($method,$key) |
|
495 | + private function setRequestInputs($method, $key) |
|
496 | 496 | { |
497 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
497 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
498 | 498 | |
499 | 499 | //check annotations for method |
500 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
501 | - $annotation->annotation($method,$key); |
|
500 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
501 | + $annotation->annotation($method, $key); |
|
502 | 502 | |
503 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
503 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
504 | 504 | |
505 | 505 | $inputKeys = $this->inputs[$key]; |
506 | 506 | |
507 | 507 | $this->inputs[$key] = []; |
508 | - foreach ($inputKeys as $input){ |
|
508 | + foreach ($inputKeys as $input) { |
|
509 | 509 | |
510 | 510 | $this->{$key} = $input; |
511 | 511 | $keyMethod = $this->{$method}(); |
512 | 512 | $this->inputs[$key][] = $keyMethod; |
513 | 513 | } |
514 | 514 | } |
515 | - else{ |
|
516 | - if(isset($this->inputs[$key])){ |
|
515 | + else { |
|
516 | + if (isset($this->inputs[$key])) { |
|
517 | 517 | $keyMethod = $this->{$method}(); |
518 | 518 | $this->inputs[$key] = $keyMethod; |
519 | 519 | } |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | { |
532 | 532 | // the auto object validate property is the property |
533 | 533 | // where all of your request values are automatically validated. |
534 | - if(property_exists($this,'autoObjectValidate') |
|
535 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
534 | + if (property_exists($this, 'autoObjectValidate') |
|
535 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
536 | 536 | $this->autoValidate('autoObjectValidate'); |
537 | 537 | } |
538 | 538 | } |
@@ -320,8 +320,7 @@ discard block |
||
320 | 320 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
321 | 321 | $this->generatorList[] = $generator; |
322 | 322 | } |
323 | - } |
|
324 | - else { |
|
323 | + } else { |
|
325 | 324 | |
326 | 325 | if($this->checkProperties('auto_generators_dont_overwrite') |
327 | 326 | && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
@@ -511,8 +510,7 @@ discard block |
||
511 | 510 | $keyMethod = $this->{$method}(); |
512 | 511 | $this->inputs[$key][] = $keyMethod; |
513 | 512 | } |
514 | - } |
|
515 | - else{ |
|
513 | + } else{ |
|
516 | 514 | if(isset($this->inputs[$key])){ |
517 | 515 | $keyMethod = $this->{$method}(); |
518 | 516 | $this->inputs[$key] = $keyMethod; |