@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @throws ReflectionExceptionAlias |
70 | 70 | */ |
71 | - public function __construct($clientData=null) |
|
71 | + public function __construct($clientData = null) |
|
72 | 72 | { |
73 | 73 | //reflection process |
74 | 74 | $this->reflection = app()['reflection']($this); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->setClientName(); |
78 | 78 | |
79 | 79 | //get http method via request http manager class |
80 | - $this->requestHttp = app()->resolve(ClientHttpManager::class,['client'=>$this]); |
|
80 | + $this->requestHttp = app()->resolve(ClientHttpManager::class, ['client'=>$this]); |
|
81 | 81 | |
82 | 82 | //get request client data |
83 | 83 | $this->clientData = ($clientData===null) ? $this->requestHttp->resolve() : $clientData; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | private function autoValidate($validate) |
95 | 95 | { |
96 | 96 | //we get the values to auto-validate. |
97 | - foreach ($this->{$validate} as $object=>$datas){ |
|
97 | + foreach ($this->{$validate} as $object=>$datas) { |
|
98 | 98 | |
99 | - if(false===Utils::isNamespaceExists($object)){ |
|
99 | + if (false===Utils::isNamespaceExists($object)) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | |
107 | 107 | // we get the index values, |
108 | 108 | // which are called methods of the auto-validate value that represents the class. |
109 | - foreach ($datas as $dataKey=>$data){ |
|
109 | + foreach ($datas as $dataKey=>$data) { |
|
110 | 110 | |
111 | 111 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
112 | 112 | // the process of auto-validate automatic implementation will be completed. |
113 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data) && isset($this->origin[$data])){ |
|
114 | - if(!is_array($this->origin[$data])){ |
|
113 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data) && isset($this->origin[$data])) { |
|
114 | + if (!is_array($this->origin[$data])) { |
|
115 | 115 | $this->origin[$data] = array($this->origin[$data]); |
116 | 116 | } |
117 | - foreach ($this->origin[$data] as $originData){ |
|
117 | + foreach ($this->origin[$data] as $originData) { |
|
118 | 118 | $getObjectInstance->{$data}($originData); |
119 | 119 | } |
120 | 120 | } |
@@ -130,22 +130,22 @@ discard block |
||
130 | 130 | private function capsule() |
131 | 131 | { |
132 | 132 | //a process can be added to the capsule array using the method. |
133 | - if(method_exists($this,'capsuleMethod')){ |
|
134 | - $this->capsule = array_merge($this->capsule,$this->capsuleMethod()); |
|
133 | + if (method_exists($this, 'capsuleMethod')) { |
|
134 | + $this->capsule = array_merge($this->capsule, $this->capsuleMethod()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // expected method is executed. |
138 | 138 | // this method is a must for http method values to be found in this property. |
139 | - if($this->checkProperties('capsule')){ |
|
139 | + if ($this->checkProperties('capsule')) { |
|
140 | 140 | |
141 | - if(property_exists($this,'auto_capsule') && is_array($this->auto_capsule)){ |
|
142 | - $this->capsule = array_merge($this->capsule,$this->auto_capsule); |
|
141 | + if (property_exists($this, 'auto_capsule') && is_array($this->auto_capsule)) { |
|
142 | + $this->capsule = array_merge($this->capsule, $this->auto_capsule); |
|
143 | 143 | } |
144 | 144 | |
145 | - foreach($this->inputs as $input=>$value){ |
|
145 | + foreach ($this->inputs as $input=>$value) { |
|
146 | 146 | |
147 | - if($this->checkProperties('capsule') && !in_array($input,$this->capsule)){ |
|
148 | - exception('clientCapsule',['key'=>$input]) |
|
147 | + if ($this->checkProperties('capsule') && !in_array($input, $this->capsule)) { |
|
148 | + exception('clientCapsule', ['key'=>$input]) |
|
149 | 149 | ->overflow('The '.$input.' value cannot be sent.'); |
150 | 150 | } |
151 | 151 | } |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | |
165 | 165 | // Determines which HTTP method |
166 | 166 | // the request object will be exposed to. |
167 | - if($this->checkProperties('http')){ |
|
167 | + if ($this->checkProperties('http')) { |
|
168 | 168 | |
169 | 169 | // if the current http method does not exist |
170 | 170 | // in the http object, the exception will be thrown. |
171 | - if(!in_array($method,$this->http)){ |
|
171 | + if (!in_array($method, $this->http)) { |
|
172 | 172 | |
173 | 173 | //exception batMethodCall |
174 | 174 | exception()->badMethodCall( |
175 | - 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
175 | + 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | // from the properties of the object properties to |
189 | 189 | // the existing variables, control the array and at least one element. |
190 | - return (property_exists($this,$properties) |
|
190 | + return (property_exists($this, $properties) |
|
191 | 191 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
192 | 192 | } |
193 | 193 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | { |
201 | 201 | // we are saving the expected values for the request in container. |
202 | 202 | // this record can be returned in exception information. |
203 | - app()->register('requestExpected',$this->expected); |
|
203 | + app()->register('requestExpected', $this->expected); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,15 +212,15 @@ discard block |
||
212 | 212 | public function except($except) |
213 | 213 | { |
214 | 214 | // the except parameter is a callable value. |
215 | - if(is_callable($except)){ |
|
216 | - $call = call_user_func_array($except,[$this]); |
|
215 | + if (is_callable($except)) { |
|
216 | + $call = call_user_func_array($except, [$this]); |
|
217 | 217 | $except = $call; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // except with the except exceptions property |
221 | 221 | // and then assigning them to the inputs property. |
222 | - $this->except = array_merge($this->except,$except); |
|
223 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
222 | + $this->except = array_merge($this->except, $except); |
|
223 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
224 | 224 | |
225 | 225 | return $this; |
226 | 226 | } |
@@ -234,27 +234,27 @@ discard block |
||
234 | 234 | { |
235 | 235 | // expected method is executed. |
236 | 236 | // this method is a must for http method values to be found in this property. |
237 | - if($this->checkProperties('expected')){ |
|
237 | + if ($this->checkProperties('expected')) { |
|
238 | 238 | |
239 | 239 | // if the expected values are not found in the inputs array, |
240 | 240 | // the exception will be thrown. |
241 | - foreach ($this->expected as $expected){ |
|
241 | + foreach ($this->expected as $expected) { |
|
242 | 242 | |
243 | 243 | $expectedValues = []; |
244 | 244 | |
245 | 245 | // mandatory expected data for each key can be separated by | operator. |
246 | 246 | // this is evaluated as "or". |
247 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
248 | - if(!isset($this->inputs[$inputs])){ |
|
247 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
248 | + if (!isset($this->inputs[$inputs])) { |
|
249 | 249 | $expectedValues[$inputs] = $inputs; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | // if the expectedData and expectedValues |
254 | 254 | // array are numerically equal to the expected key, the exception is thrown. |
255 | - if(count($expectedData)===count($expectedValues)){ |
|
256 | - exception('clientExpected',['key'=>$expected]) |
|
257 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
255 | + if (count($expectedData)===count($expectedValues)) { |
|
256 | + exception('clientExpected', ['key'=>$expected]) |
|
257 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
@@ -269,17 +269,17 @@ discard block |
||
269 | 269 | { |
270 | 270 | // check the presence of the generator object |
271 | 271 | // and operate the generator over this object. |
272 | - if($this->checkProperties('auto_generators')){ |
|
272 | + if ($this->checkProperties('auto_generators')) { |
|
273 | 273 | $generators = $this->getAutoGenerators(); |
274 | 274 | } |
275 | 275 | |
276 | 276 | // check the presence of the generator object |
277 | 277 | // and operate the generator over this object. |
278 | - if($this->checkProperties('generators')){ |
|
279 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
278 | + if ($this->checkProperties('generators')) { |
|
279 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
280 | 280 | } |
281 | 281 | |
282 | - if(isset($generators)){ |
|
282 | + if (isset($generators)) { |
|
283 | 283 | $this->generatorMethod($generators); |
284 | 284 | } |
285 | 285 | } |
@@ -294,21 +294,21 @@ discard block |
||
294 | 294 | private function generatorMethod($generators) |
295 | 295 | { |
296 | 296 | //generator array object |
297 | - foreach ($generators as $generator){ |
|
297 | + foreach ($generators as $generator) { |
|
298 | 298 | |
299 | 299 | //generator method name |
300 | 300 | $generatorMethodName = $generator.'Generator'; |
301 | 301 | |
302 | 302 | // if the generator method is present, |
303 | 303 | // the fake value is assigned. |
304 | - if(method_exists($this,$generatorMethodName)){ |
|
304 | + if (method_exists($this, $generatorMethodName)) { |
|
305 | 305 | |
306 | 306 | //fake registration |
307 | - if(!isset($this->inputs[$generator])){ |
|
307 | + if (!isset($this->inputs[$generator])) { |
|
308 | 308 | |
309 | 309 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
310 | 310 | |
311 | - if(!is_null($generatorMethodNameResult)){ |
|
311 | + if (!is_null($generatorMethodNameResult)) { |
|
312 | 312 | $this->{$generator} = $this->{$generatorMethodName}(); |
313 | 313 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
314 | 314 | $this->generatorList[] = $generator; |
@@ -316,15 +316,15 @@ discard block |
||
316 | 316 | } |
317 | 317 | else { |
318 | 318 | |
319 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
320 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
319 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
320 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
321 | 321 | $this->{$generator} = $this->{$generatorMethodName}(); |
322 | 322 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
323 | 323 | $this->generatorList[] = $generator; |
324 | 324 | } |
325 | 325 | |
326 | - if($this->checkProperties('generators_dont_overwrite') |
|
327 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
326 | + if ($this->checkProperties('generators_dont_overwrite') |
|
327 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
328 | 328 | $this->{$generator} = $this->{$generatorMethodName}(); |
329 | 329 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
330 | 330 | $this->generatorList[] = $generator; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | { |
402 | 402 | // we use the http method to write |
403 | 403 | // the values to the inputs and origin properties. |
404 | - foreach($this->clientData as $key=>$value){ |
|
404 | + foreach ($this->clientData as $key=>$value) { |
|
405 | 405 | |
406 | 406 | //inputs and origin properties |
407 | 407 | $this->inputs[$key] = $value; |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | */ |
418 | 418 | private function requestExcept() |
419 | 419 | { |
420 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
421 | - foreach ($this->requestExcept as $item){ |
|
422 | - if(isset($this->inputs[$item])){ |
|
420 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
421 | + foreach ($this->requestExcept as $item) { |
|
422 | + if (isset($this->inputs[$item])) { |
|
423 | 423 | unset($this->inputs[$item]); |
424 | 424 | } |
425 | 425 | } |
@@ -432,16 +432,16 @@ discard block |
||
432 | 432 | * @param null|string $clientName |
433 | 433 | * @return void|mixed |
434 | 434 | */ |
435 | - public function setClientName($clientName=null) |
|
435 | + public function setClientName($clientName = null) |
|
436 | 436 | { |
437 | - if(!is_null($clientName) && is_string($clientName)){ |
|
437 | + if (!is_null($clientName) && is_string($clientName)) { |
|
438 | 438 | return $this->clientName = $clientName; |
439 | 439 | } |
440 | 440 | |
441 | - if(!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])){ |
|
441 | + if (!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])) { |
|
442 | 442 | $backTrace = Utils::trace(0)['object']; |
443 | 443 | |
444 | - if(property_exists($backTrace,'clientName')){ |
|
444 | + if (property_exists($backTrace, 'clientName')) { |
|
445 | 445 | $this->clientName = $backTrace->clientName; |
446 | 446 | } |
447 | 447 | } |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | |
459 | 459 | // we update the input values after |
460 | 460 | // we receive and check the saved objects. |
461 | - foreach ($clientObjects as $key=>$value){ |
|
461 | + foreach ($clientObjects as $key=>$value) { |
|
462 | 462 | |
463 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
463 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
464 | 464 | |
465 | 465 | $this->{$key} = $clientObjects['origin'][$key]; |
466 | 466 | $this->inputs[$key] = $this->{$key}; |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | |
489 | 489 | // the request update to be performed using |
490 | 490 | // the method name to be used with the http method. |
491 | - $this->setRequestInputs($requestMethod,$key); |
|
491 | + $this->setRequestInputs($requestMethod, $key); |
|
492 | 492 | |
493 | 493 | // the request update to be performed using |
494 | 494 | // the method name to be used without the http method. |
495 | - $this->setRequestInputs($key,$key); |
|
495 | + $this->setRequestInputs($key, $key); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -503,28 +503,28 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @throws ReflectionExceptionAlias |
505 | 505 | */ |
506 | - private function setRequestInputs($method,$key) |
|
506 | + private function setRequestInputs($method, $key) |
|
507 | 507 | { |
508 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
508 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
509 | 509 | |
510 | 510 | //check annotations for method |
511 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
512 | - $annotation->annotation($method,$key); |
|
511 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
512 | + $annotation->annotation($method, $key); |
|
513 | 513 | |
514 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
514 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
515 | 515 | |
516 | 516 | $inputKeys = $this->inputs[$key]; |
517 | 517 | |
518 | 518 | $this->inputs[$key] = []; |
519 | - foreach ($inputKeys as $input){ |
|
519 | + foreach ($inputKeys as $input) { |
|
520 | 520 | |
521 | 521 | $this->{$key} = $input; |
522 | 522 | $keyMethod = $this->{$method}(); |
523 | 523 | $this->inputs[$key][] = $keyMethod; |
524 | 524 | } |
525 | 525 | } |
526 | - else{ |
|
527 | - if(isset($this->inputs[$key])){ |
|
526 | + else { |
|
527 | + if (isset($this->inputs[$key])) { |
|
528 | 528 | $keyMethod = $this->{$method}(); |
529 | 529 | $this->inputs[$key] = $keyMethod; |
530 | 530 | } |
@@ -543,8 +543,8 @@ discard block |
||
543 | 543 | // the auto object validate property is the property |
544 | 544 | // where all of your request values are automatically validated. |
545 | 545 | /** @noinspection PhpParamsInspection */ |
546 | - if(property_exists($this,'autoObjectValidate') |
|
547 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
546 | + if (property_exists($this, 'autoObjectValidate') |
|
547 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
548 | 548 | $this->autoValidate('autoObjectValidate'); |
549 | 549 | } |
550 | 550 | } |