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