@@ -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,33 +131,33 @@ 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)){ |
|
152 | - $this->inputs = array_merge($this->inputs,$groupProcess); |
|
150 | + $groupProcess = $this->groupsProcess($item, true); |
|
151 | + if (is_array($groupProcess)) { |
|
152 | + $this->inputs = array_merge($this->inputs, $groupProcess); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - foreach($this->inputs as $input=>$value){ |
|
157 | + foreach ($this->inputs as $input=>$value) { |
|
158 | 158 | |
159 | - if($this->checkProperties('capsule') && !in_array($input,$this->capsule)){ |
|
160 | - exception('clientCapsule',['key'=>$input]) |
|
159 | + if ($this->checkProperties('capsule') && !in_array($input, $this->capsule)) { |
|
160 | + exception('clientCapsule', ['key'=>$input]) |
|
161 | 161 | ->overflow('The '.$input.' value cannot be sent.'); |
162 | 162 | } |
163 | 163 | } |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | |
177 | 177 | // Determines which HTTP method |
178 | 178 | // the request object will be exposed to. |
179 | - if($this->checkProperties('http')){ |
|
179 | + if ($this->checkProperties('http')) { |
|
180 | 180 | |
181 | 181 | // if the current http method does not exist |
182 | 182 | // in the http object, the exception will be thrown. |
183 | - if(!in_array($method,$this->http)){ |
|
183 | + if (!in_array($method, $this->http)) { |
|
184 | 184 | |
185 | 185 | //exception batMethodCall |
186 | 186 | exception()->badMethodCall( |
187 | - 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
187 | + 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | // from the properties of the object properties to |
201 | 201 | // the existing variables, control the array and at least one element. |
202 | - return (property_exists($this,$properties) |
|
202 | + return (property_exists($this, $properties) |
|
203 | 203 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
204 | 204 | } |
205 | 205 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | { |
213 | 213 | // we are saving the expected values for the request in container. |
214 | 214 | // this record can be returned in exception information. |
215 | - app()->register('requestExpected',$this->expected); |
|
215 | + app()->register('requestExpected', $this->expected); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | public function except($except) |
225 | 225 | { |
226 | 226 | // the except parameter is a callable value. |
227 | - if(is_callable($except)){ |
|
228 | - $call = call_user_func_array($except,[$this]); |
|
227 | + if (is_callable($except)) { |
|
228 | + $call = call_user_func_array($except, [$this]); |
|
229 | 229 | $except = $call; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // except with the except exceptions property |
233 | 233 | // and then assigning them to the inputs property. |
234 | - $this->except = array_merge($this->except,$except); |
|
235 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
234 | + $this->except = array_merge($this->except, $except); |
|
235 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
236 | 236 | |
237 | 237 | return $this; |
238 | 238 | } |
@@ -246,32 +246,32 @@ discard block |
||
246 | 246 | { |
247 | 247 | // expected method is executed. |
248 | 248 | // this method is a must for http method values to be found in this property. |
249 | - if($this->checkProperties('expected')){ |
|
249 | + if ($this->checkProperties('expected')) { |
|
250 | 250 | |
251 | 251 | // if the expected values are not found in the inputs array, |
252 | 252 | // the exception will be thrown. |
253 | - foreach ($this->expected as $expected){ |
|
253 | + foreach ($this->expected as $expected) { |
|
254 | 254 | |
255 | 255 | $expectedValues = []; |
256 | 256 | |
257 | 257 | // mandatory expected data for each key can be separated by | operator. |
258 | 258 | // this is evaluated as "or". |
259 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
259 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
260 | 260 | |
261 | 261 | // we should do key control for group format. |
262 | 262 | // this process will allow us to perform key control for 2D array correctly. |
263 | 263 | $this->groupsProcess($inputs); |
264 | 264 | |
265 | - if(!isset($this->inputs[$inputs])){ |
|
265 | + if (!isset($this->inputs[$inputs])) { |
|
266 | 266 | $expectedValues[$inputs] = $inputs; |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | 270 | // if the expectedData and expectedValues |
271 | 271 | // array are numerically equal to the expected key, the exception is thrown. |
272 | - if(count($expectedData)===count($expectedValues)){ |
|
273 | - exception('clientExpected',['key'=>$expected]) |
|
274 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
272 | + if (count($expectedData)===count($expectedValues)) { |
|
273 | + exception('clientExpected', ['key'=>$expected]) |
|
274 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | } |
@@ -286,17 +286,17 @@ discard block |
||
286 | 286 | { |
287 | 287 | // check the presence of the generator object |
288 | 288 | // and operate the generator over this object. |
289 | - if($this->checkProperties('auto_generators')){ |
|
289 | + if ($this->checkProperties('auto_generators')) { |
|
290 | 290 | $generators = $this->getAutoGenerators(); |
291 | 291 | } |
292 | 292 | |
293 | 293 | // check the presence of the generator object |
294 | 294 | // and operate the generator over this object. |
295 | - if($this->checkProperties('generators')){ |
|
296 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
295 | + if ($this->checkProperties('generators')) { |
|
296 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
297 | 297 | } |
298 | 298 | |
299 | - if(isset($generators)){ |
|
299 | + if (isset($generators)) { |
|
300 | 300 | $this->generatorMethod($generators); |
301 | 301 | } |
302 | 302 | } |
@@ -311,21 +311,21 @@ discard block |
||
311 | 311 | private function generatorMethod($generators) |
312 | 312 | { |
313 | 313 | //generator array object |
314 | - foreach ($generators as $generator){ |
|
314 | + foreach ($generators as $generator) { |
|
315 | 315 | |
316 | 316 | //generator method name |
317 | 317 | $generatorMethodName = $generator.'Generator'; |
318 | 318 | |
319 | 319 | // if the generator method is present, |
320 | 320 | // the fake value is assigned. |
321 | - if(method_exists($this,$generatorMethodName)){ |
|
321 | + if (method_exists($this, $generatorMethodName)) { |
|
322 | 322 | |
323 | 323 | //fake registration |
324 | - if(!isset($this->inputs[$generator])){ |
|
324 | + if (!isset($this->inputs[$generator])) { |
|
325 | 325 | |
326 | 326 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
327 | 327 | |
328 | - if(!is_null($generatorMethodNameResult)){ |
|
328 | + if (!is_null($generatorMethodNameResult)) { |
|
329 | 329 | $this->{$generator} = $this->{$generatorMethodName}(); |
330 | 330 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
331 | 331 | $this->generatorList[] = $generator; |
@@ -333,15 +333,15 @@ discard block |
||
333 | 333 | } |
334 | 334 | else { |
335 | 335 | |
336 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
337 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
336 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
337 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
338 | 338 | $this->{$generator} = $this->{$generatorMethodName}(); |
339 | 339 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
340 | 340 | $this->generatorList[] = $generator; |
341 | 341 | } |
342 | 342 | |
343 | - if($this->checkProperties('generators_dont_overwrite') |
|
344 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
343 | + if ($this->checkProperties('generators_dont_overwrite') |
|
344 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
345 | 345 | $this->{$generator} = $this->{$generatorMethodName}(); |
346 | 346 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
347 | 347 | $this->generatorList[] = $generator; |
@@ -372,27 +372,27 @@ discard block |
||
372 | 372 | * @param null $callback |
373 | 373 | * @return mixed|void |
374 | 374 | */ |
375 | - public function groupsProcess($key=null,$callback=null) |
|
375 | + public function groupsProcess($key = null, $callback = null) |
|
376 | 376 | { |
377 | - if(property_exists($this,'groups') && is_array($this->groups)){ |
|
377 | + if (property_exists($this, 'groups') && is_array($this->groups)) { |
|
378 | 378 | |
379 | 379 | $clientObjects = $this->getClientObjects(); |
380 | 380 | |
381 | - foreach ($this->groups as $group){ |
|
381 | + foreach ($this->groups as $group) { |
|
382 | 382 | |
383 | - if(true === $callback){ |
|
384 | - if(isset($clientObjects['origin'][$key])){ |
|
383 | + if (true===$callback) { |
|
384 | + if (isset($clientObjects['origin'][$key])) { |
|
385 | 385 | return $clientObjects['origin'][$key]; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | - if(isset($clientObjects['origin'][$group][$key])){ |
|
389 | + if (isset($clientObjects['origin'][$group][$key])) { |
|
390 | 390 | |
391 | 391 | $this->{$key} = $clientObjects['origin'][$group][$key]; |
392 | 392 | $this->inputs[$key] = $this->{$key}; |
393 | 393 | |
394 | - if(is_callable($callback)){ |
|
395 | - call_user_func_array($callback,[$key]); |
|
394 | + if (is_callable($callback)) { |
|
395 | + call_user_func_array($callback, [$key]); |
|
396 | 396 | } |
397 | 397 | } |
398 | 398 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | { |
456 | 456 | // we use the http method to write |
457 | 457 | // the values to the inputs and origin properties. |
458 | - foreach($this->clientData as $key=>$value){ |
|
458 | + foreach ($this->clientData as $key=>$value) { |
|
459 | 459 | |
460 | 460 | //inputs and origin properties |
461 | 461 | $this->inputs[$key] = $value; |
@@ -471,9 +471,9 @@ discard block |
||
471 | 471 | */ |
472 | 472 | private function requestExcept() |
473 | 473 | { |
474 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
475 | - foreach ($this->requestExcept as $item){ |
|
476 | - if(isset($this->inputs[$item])){ |
|
474 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
475 | + foreach ($this->requestExcept as $item) { |
|
476 | + if (isset($this->inputs[$item])) { |
|
477 | 477 | unset($this->inputs[$item]); |
478 | 478 | } |
479 | 479 | } |
@@ -486,16 +486,16 @@ discard block |
||
486 | 486 | * @param null|string $clientName |
487 | 487 | * @return void|mixed |
488 | 488 | */ |
489 | - public function setClientName($clientName=null) |
|
489 | + public function setClientName($clientName = null) |
|
490 | 490 | { |
491 | - if(!is_null($clientName) && is_string($clientName)){ |
|
491 | + if (!is_null($clientName) && is_string($clientName)) { |
|
492 | 492 | return $this->clientName = $clientName; |
493 | 493 | } |
494 | 494 | |
495 | - if(!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])){ |
|
495 | + if (!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])) { |
|
496 | 496 | $backTrace = Utils::trace(0)['object']; |
497 | 497 | |
498 | - if(property_exists($backTrace,'clientName')){ |
|
498 | + if (property_exists($backTrace, 'clientName')) { |
|
499 | 499 | $this->clientName = $backTrace->clientName; |
500 | 500 | } |
501 | 501 | } |
@@ -512,16 +512,16 @@ discard block |
||
512 | 512 | |
513 | 513 | // we update the input values after |
514 | 514 | // we receive and check the saved objects. |
515 | - foreach ($clientObjects as $key=>$value){ |
|
515 | + foreach ($clientObjects as $key=>$value) { |
|
516 | 516 | |
517 | 517 | // we should do key control for group format. |
518 | 518 | // this process will allow us to perform key control for 2D array correctly. |
519 | - $this->groupsProcess($key,function($key){ |
|
519 | + $this->groupsProcess($key, function($key) { |
|
520 | 520 | $this->registerRequestInputs($key); |
521 | 521 | unset($this->inputs[$key]); |
522 | 522 | }); |
523 | 523 | |
524 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
524 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
525 | 525 | |
526 | 526 | $this->{$key} = $clientObjects['origin'][$key]; |
527 | 527 | $this->inputs[$key] = $this->{$key}; |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | |
550 | 550 | // the request update to be performed using |
551 | 551 | // the method name to be used with the http method. |
552 | - $this->setRequestInputs($requestMethod,$key); |
|
552 | + $this->setRequestInputs($requestMethod, $key); |
|
553 | 553 | |
554 | 554 | // the request update to be performed using |
555 | 555 | // the method name to be used without the http method. |
556 | - $this->setRequestInputs($key,$key); |
|
556 | + $this->setRequestInputs($key, $key); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -564,28 +564,28 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @throws ReflectionExceptionAlias |
566 | 566 | */ |
567 | - private function setRequestInputs($method,$key) |
|
567 | + private function setRequestInputs($method, $key) |
|
568 | 568 | { |
569 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
569 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
570 | 570 | |
571 | 571 | //check annotations for method |
572 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
573 | - $annotation->annotation($method,$key); |
|
572 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
573 | + $annotation->annotation($method, $key); |
|
574 | 574 | |
575 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
575 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
576 | 576 | |
577 | 577 | $inputKeys = $this->inputs[$key]; |
578 | 578 | |
579 | 579 | $this->inputs[$key] = []; |
580 | - foreach ($inputKeys as $input){ |
|
580 | + foreach ($inputKeys as $input) { |
|
581 | 581 | |
582 | 582 | $this->{$key} = $input; |
583 | 583 | $keyMethod = $this->{$method}(); |
584 | 584 | $this->inputs[$key][] = $keyMethod; |
585 | 585 | } |
586 | 586 | } |
587 | - else{ |
|
588 | - if(isset($this->inputs[$key])){ |
|
587 | + else { |
|
588 | + if (isset($this->inputs[$key])) { |
|
589 | 589 | $keyMethod = $this->{$method}(); |
590 | 590 | $this->inputs[$key] = $keyMethod; |
591 | 591 | } |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | // the auto object validate property is the property |
605 | 605 | // where all of your request values are automatically validated. |
606 | 606 | /** @noinspection PhpParamsInspection */ |
607 | - if(property_exists($this,'autoObjectValidate') |
|
608 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
607 | + if (property_exists($this, 'autoObjectValidate') |
|
608 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
609 | 609 | $this->autoValidate('autoObjectValidate'); |
610 | 610 | } |
611 | 611 | } |