@@ -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,39 +131,39 @@ 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 | - if($this->checkProperties('groups')){ |
|
147 | - $this->capsule = array_merge($this->capsule,$this->groups); |
|
146 | + if ($this->checkProperties('groups')) { |
|
147 | + $this->capsule = array_merge($this->capsule, $this->groups); |
|
148 | 148 | |
149 | 149 | foreach ($this->capsule as $item) { |
150 | - $groupProcess = $this->groupsProcess($item,true); |
|
151 | - if(is_array($groupProcess)){ |
|
150 | + $groupProcess = $this->groupsProcess($item, true); |
|
151 | + if (is_array($groupProcess)) { |
|
152 | 152 | $defaultInputs = $this->inputs; |
153 | - $this->inputs = array_merge($this->inputs,$groupProcess); |
|
153 | + $this->inputs = array_merge($this->inputs, $groupProcess); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - foreach($this->inputs as $input=>$value){ |
|
158 | + foreach ($this->inputs as $input=>$value) { |
|
159 | 159 | |
160 | - if($this->checkProperties('capsule') && !in_array($input,$this->capsule)){ |
|
161 | - exception('clientCapsule',['key'=>$input]) |
|
160 | + if ($this->checkProperties('capsule') && !in_array($input, $this->capsule)) { |
|
161 | + exception('clientCapsule', ['key'=>$input]) |
|
162 | 162 | ->overflow('The '.$input.' value cannot be sent.'); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - if(isset($defaultInputs)){ |
|
166 | + if (isset($defaultInputs)) { |
|
167 | 167 | $this->inputs = $defaultInputs; |
168 | 168 | } |
169 | 169 | } |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | |
182 | 182 | // Determines which HTTP method |
183 | 183 | // the request object will be exposed to. |
184 | - if($this->checkProperties('http')){ |
|
184 | + if ($this->checkProperties('http')) { |
|
185 | 185 | |
186 | 186 | // if the current http method does not exist |
187 | 187 | // in the http object, the exception will be thrown. |
188 | - if(!in_array($method,$this->http)){ |
|
188 | + if (!in_array($method, $this->http)) { |
|
189 | 189 | |
190 | 190 | //exception batMethodCall |
191 | 191 | exception()->badMethodCall( |
192 | - 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
192 | + 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | { |
205 | 205 | // from the properties of the object properties to |
206 | 206 | // the existing variables, control the array and at least one element. |
207 | - return (property_exists($this,$properties) |
|
207 | + return (property_exists($this, $properties) |
|
208 | 208 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
209 | 209 | } |
210 | 210 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | { |
218 | 218 | // we are saving the expected values for the request in container. |
219 | 219 | // this record can be returned in exception information. |
220 | - app()->register('requestExpected',$this->expected); |
|
220 | + app()->register('requestExpected', $this->expected); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | public function except($except) |
230 | 230 | { |
231 | 231 | // the except parameter is a callable value. |
232 | - if(is_callable($except)){ |
|
233 | - $call = call_user_func_array($except,[$this]); |
|
232 | + if (is_callable($except)) { |
|
233 | + $call = call_user_func_array($except, [$this]); |
|
234 | 234 | $except = $call; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // except with the except exceptions property |
238 | 238 | // and then assigning them to the inputs property. |
239 | - $this->except = array_merge($this->except,$except); |
|
240 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
239 | + $this->except = array_merge($this->except, $except); |
|
240 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
241 | 241 | |
242 | 242 | return $this; |
243 | 243 | } |
@@ -251,32 +251,32 @@ discard block |
||
251 | 251 | { |
252 | 252 | // expected method is executed. |
253 | 253 | // this method is a must for http method values to be found in this property. |
254 | - if($this->checkProperties('expected')){ |
|
254 | + if ($this->checkProperties('expected')) { |
|
255 | 255 | |
256 | 256 | // if the expected values are not found in the inputs array, |
257 | 257 | // the exception will be thrown. |
258 | - foreach ($this->expected as $expected){ |
|
258 | + foreach ($this->expected as $expected) { |
|
259 | 259 | |
260 | 260 | $expectedValues = []; |
261 | 261 | |
262 | 262 | // mandatory expected data for each key can be separated by | operator. |
263 | 263 | // this is evaluated as "or". |
264 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
264 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
265 | 265 | |
266 | 266 | // we should do key control for group format. |
267 | 267 | // this process will allow us to perform key control for 2D array correctly. |
268 | 268 | $this->groupsProcess($inputs); |
269 | 269 | |
270 | - if(!isset($this->inputs[$inputs])){ |
|
270 | + if (!isset($this->inputs[$inputs])) { |
|
271 | 271 | $expectedValues[$inputs] = $inputs; |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | 275 | // if the expectedData and expectedValues |
276 | 276 | // array are numerically equal to the expected key, the exception is thrown. |
277 | - if(count($expectedData)===count($expectedValues)){ |
|
278 | - exception('clientExpected',['key'=>$expected]) |
|
279 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
277 | + if (count($expectedData)===count($expectedValues)) { |
|
278 | + exception('clientExpected', ['key'=>$expected]) |
|
279 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | } |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | { |
292 | 292 | // check the presence of the generator object |
293 | 293 | // and operate the generator over this object. |
294 | - if($this->checkProperties('auto_generators')){ |
|
294 | + if ($this->checkProperties('auto_generators')) { |
|
295 | 295 | $generators = $this->getAutoGenerators(); |
296 | 296 | } |
297 | 297 | |
298 | 298 | // check the presence of the generator object |
299 | 299 | // and operate the generator over this object. |
300 | - if($this->checkProperties('generators')){ |
|
301 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
300 | + if ($this->checkProperties('generators')) { |
|
301 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
302 | 302 | } |
303 | 303 | |
304 | - if(isset($generators)){ |
|
304 | + if (isset($generators)) { |
|
305 | 305 | $this->generatorMethod($generators); |
306 | 306 | } |
307 | 307 | } |
@@ -316,21 +316,21 @@ discard block |
||
316 | 316 | private function generatorMethod($generators) |
317 | 317 | { |
318 | 318 | //generator array object |
319 | - foreach ($generators as $generator){ |
|
319 | + foreach ($generators as $generator) { |
|
320 | 320 | |
321 | 321 | //generator method name |
322 | 322 | $generatorMethodName = $generator.'Generator'; |
323 | 323 | |
324 | 324 | // if the generator method is present, |
325 | 325 | // the fake value is assigned. |
326 | - if(method_exists($this,$generatorMethodName)){ |
|
326 | + if (method_exists($this, $generatorMethodName)) { |
|
327 | 327 | |
328 | 328 | //fake registration |
329 | - if(!isset($this->inputs[$generator])){ |
|
329 | + if (!isset($this->inputs[$generator])) { |
|
330 | 330 | |
331 | 331 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
332 | 332 | |
333 | - if(!is_null($generatorMethodNameResult)){ |
|
333 | + if (!is_null($generatorMethodNameResult)) { |
|
334 | 334 | $this->{$generator} = $this->{$generatorMethodName}(); |
335 | 335 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
336 | 336 | $this->generatorList[] = $generator; |
@@ -338,15 +338,15 @@ discard block |
||
338 | 338 | } |
339 | 339 | else { |
340 | 340 | |
341 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
342 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
341 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
342 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
343 | 343 | $this->{$generator} = $this->{$generatorMethodName}(); |
344 | 344 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
345 | 345 | $this->generatorList[] = $generator; |
346 | 346 | } |
347 | 347 | |
348 | - if($this->checkProperties('generators_dont_overwrite') |
|
349 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
348 | + if ($this->checkProperties('generators_dont_overwrite') |
|
349 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
350 | 350 | $this->{$generator} = $this->{$generatorMethodName}(); |
351 | 351 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
352 | 352 | $this->generatorList[] = $generator; |
@@ -377,28 +377,28 @@ discard block |
||
377 | 377 | * @param null $callback |
378 | 378 | * @return mixed|void |
379 | 379 | */ |
380 | - public function groupsProcess($key=null,$callback=null) |
|
380 | + public function groupsProcess($key = null, $callback = null) |
|
381 | 381 | { |
382 | - if(property_exists($this,'groups') && is_array($this->groups)){ |
|
382 | + if (property_exists($this, 'groups') && is_array($this->groups)) { |
|
383 | 383 | |
384 | 384 | $clientObjects = $this->getClientObjects(); |
385 | 385 | |
386 | - foreach ($this->groups as $group){ |
|
386 | + foreach ($this->groups as $group) { |
|
387 | 387 | |
388 | - if(true === $callback){ |
|
389 | - if(isset($clientObjects['origin'][$key])){ |
|
388 | + if (true===$callback) { |
|
389 | + if (isset($clientObjects['origin'][$key])) { |
|
390 | 390 | return $clientObjects['origin'][$key]; |
391 | 391 | } |
392 | 392 | return []; |
393 | 393 | } |
394 | 394 | |
395 | - if(isset($clientObjects['origin'][$group][$key])){ |
|
395 | + if (isset($clientObjects['origin'][$group][$key])) { |
|
396 | 396 | |
397 | 397 | $this->{$key} = $clientObjects['origin'][$group][$key]; |
398 | 398 | $this->inputs[$key] = $this->{$key}; |
399 | 399 | |
400 | - if(is_callable($callback)){ |
|
401 | - call_user_func_array($callback,[$key]); |
|
400 | + if (is_callable($callback)) { |
|
401 | + call_user_func_array($callback, [$key]); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | { |
462 | 462 | // we use the http method to write |
463 | 463 | // the values to the inputs and origin properties. |
464 | - foreach($this->clientData as $key=>$value){ |
|
464 | + foreach ($this->clientData as $key=>$value) { |
|
465 | 465 | |
466 | 466 | //inputs and origin properties |
467 | 467 | $this->inputs[$key] = $value; |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | */ |
478 | 478 | private function requestExcept() |
479 | 479 | { |
480 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
481 | - foreach ($this->requestExcept as $item){ |
|
482 | - if(isset($this->inputs[$item])){ |
|
480 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
481 | + foreach ($this->requestExcept as $item) { |
|
482 | + if (isset($this->inputs[$item])) { |
|
483 | 483 | unset($this->inputs[$item]); |
484 | 484 | } |
485 | 485 | } |
@@ -492,16 +492,16 @@ discard block |
||
492 | 492 | * @param null|string $clientName |
493 | 493 | * @return void|mixed |
494 | 494 | */ |
495 | - public function setClientName($clientName=null) |
|
495 | + public function setClientName($clientName = null) |
|
496 | 496 | { |
497 | - if(!is_null($clientName) && is_string($clientName)){ |
|
497 | + if (!is_null($clientName) && is_string($clientName)) { |
|
498 | 498 | return $this->clientName = $clientName; |
499 | 499 | } |
500 | 500 | |
501 | - if(!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])){ |
|
501 | + if (!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])) { |
|
502 | 502 | $backTrace = Utils::trace(0)['object']; |
503 | 503 | |
504 | - if(property_exists($backTrace,'clientName')){ |
|
504 | + if (property_exists($backTrace, 'clientName')) { |
|
505 | 505 | $this->clientName = $backTrace->clientName; |
506 | 506 | } |
507 | 507 | } |
@@ -518,16 +518,16 @@ discard block |
||
518 | 518 | |
519 | 519 | // we update the input values after |
520 | 520 | // we receive and check the saved objects. |
521 | - foreach ($clientObjects as $key=>$value){ |
|
521 | + foreach ($clientObjects as $key=>$value) { |
|
522 | 522 | |
523 | 523 | // we should do key control for group format. |
524 | 524 | // this process will allow us to perform key control for 2D array correctly. |
525 | - $this->groupsProcess($key,function($key){ |
|
525 | + $this->groupsProcess($key, function($key) { |
|
526 | 526 | $this->registerRequestInputs($key); |
527 | 527 | unset($this->inputs[$key]); |
528 | 528 | }); |
529 | 529 | |
530 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
530 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
531 | 531 | |
532 | 532 | $this->{$key} = $clientObjects['origin'][$key]; |
533 | 533 | $this->inputs[$key] = $this->{$key}; |
@@ -555,11 +555,11 @@ discard block |
||
555 | 555 | |
556 | 556 | // the request update to be performed using |
557 | 557 | // the method name to be used with the http method. |
558 | - $this->setRequestInputs($requestMethod,$key); |
|
558 | + $this->setRequestInputs($requestMethod, $key); |
|
559 | 559 | |
560 | 560 | // the request update to be performed using |
561 | 561 | // the method name to be used without the http method. |
562 | - $this->setRequestInputs($key,$key); |
|
562 | + $this->setRequestInputs($key, $key); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | /** |
@@ -570,28 +570,28 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @throws ReflectionExceptionAlias |
572 | 572 | */ |
573 | - private function setRequestInputs($method,$key) |
|
573 | + private function setRequestInputs($method, $key) |
|
574 | 574 | { |
575 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
575 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
576 | 576 | |
577 | 577 | //check annotations for method |
578 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
579 | - $annotation->annotation($method,$key); |
|
578 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
579 | + $annotation->annotation($method, $key); |
|
580 | 580 | |
581 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
581 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
582 | 582 | |
583 | 583 | $inputKeys = $this->inputs[$key]; |
584 | 584 | |
585 | 585 | $this->inputs[$key] = []; |
586 | - foreach ($inputKeys as $input){ |
|
586 | + foreach ($inputKeys as $input) { |
|
587 | 587 | |
588 | 588 | $this->{$key} = $input; |
589 | 589 | $keyMethod = $this->{$method}(); |
590 | 590 | $this->inputs[$key][] = $keyMethod; |
591 | 591 | } |
592 | 592 | } |
593 | - else{ |
|
594 | - if(isset($this->inputs[$key])){ |
|
593 | + else { |
|
594 | + if (isset($this->inputs[$key])) { |
|
595 | 595 | $keyMethod = $this->{$method}(); |
596 | 596 | $this->inputs[$key] = $keyMethod; |
597 | 597 | } |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | // the auto object validate property is the property |
611 | 611 | // where all of your request values are automatically validated. |
612 | 612 | /** @noinspection PhpParamsInspection */ |
613 | - if(property_exists($this,'autoObjectValidate') |
|
614 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
613 | + if (property_exists($this, 'autoObjectValidate') |
|
614 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
615 | 615 | $this->autoValidate('autoObjectValidate'); |
616 | 616 | } |
617 | 617 | } |