@@ -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,13 +107,13 @@ 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(method_exists($getObjectInstance,$dataKey) && is_array($data)){ |
|
115 | - foreach ($data as $dataItem){ |
|
116 | - if(isset($this->origin[$dataItem])){ |
|
114 | + if (method_exists($getObjectInstance, $dataKey) && is_array($data)) { |
|
115 | + foreach ($data as $dataItem) { |
|
116 | + if (isset($this->origin[$dataItem])) { |
|
117 | 117 | $getObjectInstance->{$dataKey}($this->origin[$dataItem]); |
118 | 118 | } |
119 | 119 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | |
122 | 122 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
123 | 123 | // the process of auto-validate automatic implementation will be completed. |
124 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data) && isset($this->origin[$data])){ |
|
125 | - if(!is_array($this->origin[$data])){ |
|
124 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data) && isset($this->origin[$data])) { |
|
125 | + if (!is_array($this->origin[$data])) { |
|
126 | 126 | $this->origin[$data] = array($this->origin[$data]); |
127 | 127 | } |
128 | - foreach ($this->origin[$data] as $originData){ |
|
128 | + foreach ($this->origin[$data] as $originData) { |
|
129 | 129 | $getObjectInstance->{$data}($originData); |
130 | 130 | } |
131 | 131 | } |
@@ -141,39 +141,39 @@ discard block |
||
141 | 141 | private function capsule() |
142 | 142 | { |
143 | 143 | //a process can be added to the capsule array using the method. |
144 | - if(method_exists($this,'capsuleMethod')){ |
|
145 | - $this->capsule = array_merge($this->capsule,$this->capsuleMethod()); |
|
144 | + if (method_exists($this, 'capsuleMethod')) { |
|
145 | + $this->capsule = array_merge($this->capsule, $this->capsuleMethod()); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // expected method is executed. |
149 | 149 | // this method is a must for http method values to be found in this property. |
150 | - if($this->checkProperties('capsule')){ |
|
150 | + if ($this->checkProperties('capsule')) { |
|
151 | 151 | |
152 | - if(property_exists($this,'auto_capsule') && is_array($this->auto_capsule)){ |
|
153 | - $this->capsule = array_merge($this->capsule,$this->auto_capsule); |
|
152 | + if (property_exists($this, 'auto_capsule') && is_array($this->auto_capsule)) { |
|
153 | + $this->capsule = array_merge($this->capsule, $this->auto_capsule); |
|
154 | 154 | } |
155 | 155 | |
156 | - if($this->checkProperties('groups')){ |
|
157 | - $this->capsule = array_merge($this->capsule,$this->groups); |
|
156 | + if ($this->checkProperties('groups')) { |
|
157 | + $this->capsule = array_merge($this->capsule, $this->groups); |
|
158 | 158 | |
159 | 159 | foreach ($this->capsule as $item) { |
160 | - $groupProcess = $this->groupsProcess($item,true); |
|
161 | - if(is_array($groupProcess)){ |
|
160 | + $groupProcess = $this->groupsProcess($item, true); |
|
161 | + if (is_array($groupProcess)) { |
|
162 | 162 | $defaultInputs = $this->inputs; |
163 | - $this->inputs = array_merge($this->inputs,$groupProcess); |
|
163 | + $this->inputs = array_merge($this->inputs, $groupProcess); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - foreach($this->inputs as $input=>$value){ |
|
168 | + foreach ($this->inputs as $input=>$value) { |
|
169 | 169 | |
170 | - if($this->checkProperties('capsule') && !in_array($input,$this->capsule)){ |
|
171 | - exception('clientCapsule',['key'=>$input]) |
|
170 | + if ($this->checkProperties('capsule') && !in_array($input, $this->capsule)) { |
|
171 | + exception('clientCapsule', ['key'=>$input]) |
|
172 | 172 | ->overflow('The '.$input.' value cannot be sent.'); |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - if(isset($defaultInputs)){ |
|
176 | + if (isset($defaultInputs)) { |
|
177 | 177 | $this->inputs = $defaultInputs; |
178 | 178 | } |
179 | 179 | } |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | |
192 | 192 | // Determines which HTTP method |
193 | 193 | // the request object will be exposed to. |
194 | - if($this->checkProperties('http')){ |
|
194 | + if ($this->checkProperties('http')) { |
|
195 | 195 | |
196 | 196 | // if the current http method does not exist |
197 | 197 | // in the http object, the exception will be thrown. |
198 | - if(!in_array($method,$this->http)){ |
|
198 | + if (!in_array($method, $this->http)) { |
|
199 | 199 | |
200 | 200 | //exception batMethodCall |
201 | 201 | exception()->badMethodCall( |
202 | - 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
202 | + 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | { |
215 | 215 | // from the properties of the object properties to |
216 | 216 | // the existing variables, control the array and at least one element. |
217 | - return (property_exists($this,$properties) |
|
217 | + return (property_exists($this, $properties) |
|
218 | 218 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
219 | 219 | } |
220 | 220 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | // we are saving the expected values for the request in container. |
229 | 229 | // this record can be returned in exception information. |
230 | - app()->register('requestExpected',$this->expected); |
|
230 | + app()->register('requestExpected', $this->expected); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -239,15 +239,15 @@ discard block |
||
239 | 239 | public function except($except) |
240 | 240 | { |
241 | 241 | // the except parameter is a callable value. |
242 | - if(is_callable($except)){ |
|
243 | - $call = call_user_func_array($except,[$this]); |
|
242 | + if (is_callable($except)) { |
|
243 | + $call = call_user_func_array($except, [$this]); |
|
244 | 244 | $except = $call; |
245 | 245 | } |
246 | 246 | |
247 | 247 | // except with the except exceptions property |
248 | 248 | // and then assigning them to the inputs property. |
249 | - $this->except = array_merge($this->except,$except); |
|
250 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
249 | + $this->except = array_merge($this->except, $except); |
|
250 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
251 | 251 | |
252 | 252 | return $this; |
253 | 253 | } |
@@ -261,32 +261,32 @@ discard block |
||
261 | 261 | { |
262 | 262 | // expected method is executed. |
263 | 263 | // this method is a must for http method values to be found in this property. |
264 | - if($this->checkProperties('expected')){ |
|
264 | + if ($this->checkProperties('expected')) { |
|
265 | 265 | |
266 | 266 | // if the expected values are not found in the inputs array, |
267 | 267 | // the exception will be thrown. |
268 | - foreach ($this->expected as $expected){ |
|
268 | + foreach ($this->expected as $expected) { |
|
269 | 269 | |
270 | 270 | $expectedValues = []; |
271 | 271 | |
272 | 272 | // mandatory expected data for each key can be separated by | operator. |
273 | 273 | // this is evaluated as "or". |
274 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
274 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
275 | 275 | |
276 | 276 | // we should do key control for group format. |
277 | 277 | // this process will allow us to perform key control for 2D array correctly. |
278 | 278 | $this->groupsProcess($inputs); |
279 | 279 | |
280 | - if(!isset($this->inputs[$inputs])){ |
|
280 | + if (!isset($this->inputs[$inputs])) { |
|
281 | 281 | $expectedValues[$inputs] = $inputs; |
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | 285 | // if the expectedData and expectedValues |
286 | 286 | // array are numerically equal to the expected key, the exception is thrown. |
287 | - if(count($expectedData)===count($expectedValues)){ |
|
288 | - exception('clientExpected',['key'=>$expected]) |
|
289 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
287 | + if (count($expectedData)===count($expectedValues)) { |
|
288 | + exception('clientExpected', ['key'=>$expected]) |
|
289 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | } |
@@ -301,17 +301,17 @@ discard block |
||
301 | 301 | { |
302 | 302 | // check the presence of the generator object |
303 | 303 | // and operate the generator over this object. |
304 | - if($this->checkProperties('auto_generators')){ |
|
304 | + if ($this->checkProperties('auto_generators')) { |
|
305 | 305 | $generators = $this->getAutoGenerators(); |
306 | 306 | } |
307 | 307 | |
308 | 308 | // check the presence of the generator object |
309 | 309 | // and operate the generator over this object. |
310 | - if($this->checkProperties('generators')){ |
|
311 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
310 | + if ($this->checkProperties('generators')) { |
|
311 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
312 | 312 | } |
313 | 313 | |
314 | - if(isset($generators)){ |
|
314 | + if (isset($generators)) { |
|
315 | 315 | $this->generatorMethod($generators); |
316 | 316 | } |
317 | 317 | } |
@@ -326,21 +326,21 @@ discard block |
||
326 | 326 | private function generatorMethod($generators) |
327 | 327 | { |
328 | 328 | //generator array object |
329 | - foreach ($generators as $generator){ |
|
329 | + foreach ($generators as $generator) { |
|
330 | 330 | |
331 | 331 | //generator method name |
332 | 332 | $generatorMethodName = $generator.'Generator'; |
333 | 333 | |
334 | 334 | // if the generator method is present, |
335 | 335 | // the fake value is assigned. |
336 | - if(method_exists($this,$generatorMethodName)){ |
|
336 | + if (method_exists($this, $generatorMethodName)) { |
|
337 | 337 | |
338 | 338 | //fake registration |
339 | - if(!isset($this->inputs[$generator])){ |
|
339 | + if (!isset($this->inputs[$generator])) { |
|
340 | 340 | |
341 | 341 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
342 | 342 | |
343 | - if(!is_null($generatorMethodNameResult)){ |
|
343 | + if (!is_null($generatorMethodNameResult)) { |
|
344 | 344 | $this->{$generator} = $this->{$generatorMethodName}(); |
345 | 345 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
346 | 346 | $this->generatorList[] = $generator; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | } |
349 | 349 | else { |
350 | 350 | |
351 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
352 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
351 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
352 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
353 | 353 | $this->{$generator} = $this->{$generatorMethodName}(); |
354 | 354 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
355 | 355 | $this->generatorList[] = $generator; |
356 | 356 | } |
357 | 357 | |
358 | - if($this->checkProperties('generators_dont_overwrite') |
|
359 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
358 | + if ($this->checkProperties('generators_dont_overwrite') |
|
359 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
360 | 360 | $this->{$generator} = $this->{$generatorMethodName}(); |
361 | 361 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
362 | 362 | $this->generatorList[] = $generator; |
@@ -387,28 +387,28 @@ discard block |
||
387 | 387 | * @param null $callback |
388 | 388 | * @return mixed|void |
389 | 389 | */ |
390 | - public function groupsProcess($key=null,$callback=null) |
|
390 | + public function groupsProcess($key = null, $callback = null) |
|
391 | 391 | { |
392 | - if(property_exists($this,'groups') && is_array($this->groups)){ |
|
392 | + if (property_exists($this, 'groups') && is_array($this->groups)) { |
|
393 | 393 | |
394 | 394 | $clientObjects = $this->getClientObjects(); |
395 | 395 | |
396 | - foreach ($this->groups as $group){ |
|
396 | + foreach ($this->groups as $group) { |
|
397 | 397 | |
398 | - if(true === $callback){ |
|
399 | - if(isset($clientObjects['origin'][$key])){ |
|
398 | + if (true===$callback) { |
|
399 | + if (isset($clientObjects['origin'][$key])) { |
|
400 | 400 | return $clientObjects['origin'][$key]; |
401 | 401 | } |
402 | 402 | return []; |
403 | 403 | } |
404 | 404 | |
405 | - if(isset($clientObjects['origin'][$group][$key])){ |
|
405 | + if (isset($clientObjects['origin'][$group][$key])) { |
|
406 | 406 | |
407 | 407 | $this->{$key} = $clientObjects['origin'][$group][$key]; |
408 | 408 | $this->inputs[$key] = $this->{$key}; |
409 | 409 | |
410 | - if(is_callable($callback)){ |
|
411 | - call_user_func_array($callback,[$key]); |
|
410 | + if (is_callable($callback)) { |
|
411 | + call_user_func_array($callback, [$key]); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | { |
472 | 472 | // we use the http method to write |
473 | 473 | // the values to the inputs and origin properties. |
474 | - foreach($this->clientData as $key=>$value){ |
|
474 | + foreach ($this->clientData as $key=>$value) { |
|
475 | 475 | |
476 | 476 | //inputs and origin properties |
477 | 477 | $this->inputs[$key] = $value; |
@@ -487,9 +487,9 @@ discard block |
||
487 | 487 | */ |
488 | 488 | private function requestExcept() |
489 | 489 | { |
490 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
491 | - foreach ($this->requestExcept as $item){ |
|
492 | - if(isset($this->inputs[$item])){ |
|
490 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
491 | + foreach ($this->requestExcept as $item) { |
|
492 | + if (isset($this->inputs[$item])) { |
|
493 | 493 | unset($this->inputs[$item]); |
494 | 494 | } |
495 | 495 | } |
@@ -502,16 +502,16 @@ discard block |
||
502 | 502 | * @param null|string $clientName |
503 | 503 | * @return void|mixed |
504 | 504 | */ |
505 | - public function setClientName($clientName=null) |
|
505 | + public function setClientName($clientName = null) |
|
506 | 506 | { |
507 | - if(!is_null($clientName) && is_string($clientName)){ |
|
507 | + if (!is_null($clientName) && is_string($clientName)) { |
|
508 | 508 | return $this->clientName = $clientName; |
509 | 509 | } |
510 | 510 | |
511 | - if(!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])){ |
|
511 | + if (!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])) { |
|
512 | 512 | $backTrace = Utils::trace(0)['object']; |
513 | 513 | |
514 | - if(property_exists($backTrace,'clientName')){ |
|
514 | + if (property_exists($backTrace, 'clientName')) { |
|
515 | 515 | $this->clientName = $backTrace->clientName; |
516 | 516 | } |
517 | 517 | } |
@@ -528,16 +528,16 @@ discard block |
||
528 | 528 | |
529 | 529 | // we update the input values after |
530 | 530 | // we receive and check the saved objects. |
531 | - foreach ($clientObjects as $key=>$value){ |
|
531 | + foreach ($clientObjects as $key=>$value) { |
|
532 | 532 | |
533 | 533 | // we should do key control for group format. |
534 | 534 | // this process will allow us to perform key control for 2D array correctly. |
535 | - $this->groupsProcess($key,function($key){ |
|
535 | + $this->groupsProcess($key, function($key) { |
|
536 | 536 | $this->registerRequestInputs($key); |
537 | 537 | unset($this->inputs[$key]); |
538 | 538 | }); |
539 | 539 | |
540 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
540 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
541 | 541 | |
542 | 542 | $this->{$key} = $clientObjects['origin'][$key]; |
543 | 543 | $this->inputs[$key] = $this->{$key}; |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | |
566 | 566 | // the request update to be performed using |
567 | 567 | // the method name to be used with the http method. |
568 | - $this->setRequestInputs($requestMethod,$key); |
|
568 | + $this->setRequestInputs($requestMethod, $key); |
|
569 | 569 | |
570 | 570 | // the request update to be performed using |
571 | 571 | // the method name to be used without the http method. |
572 | - $this->setRequestInputs($key,$key); |
|
572 | + $this->setRequestInputs($key, $key); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -580,28 +580,28 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @throws ReflectionExceptionAlias |
582 | 582 | */ |
583 | - private function setRequestInputs($method,$key) |
|
583 | + private function setRequestInputs($method, $key) |
|
584 | 584 | { |
585 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
585 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
586 | 586 | |
587 | 587 | //check annotations for method |
588 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
589 | - $annotation->annotation($method,$key); |
|
588 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
589 | + $annotation->annotation($method, $key); |
|
590 | 590 | |
591 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
591 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
592 | 592 | |
593 | 593 | $inputKeys = $this->inputs[$key]; |
594 | 594 | |
595 | 595 | $this->inputs[$key] = []; |
596 | - foreach ($inputKeys as $input){ |
|
596 | + foreach ($inputKeys as $input) { |
|
597 | 597 | |
598 | 598 | $this->{$key} = $input; |
599 | 599 | $keyMethod = $this->{$method}(); |
600 | 600 | $this->inputs[$key][] = $keyMethod; |
601 | 601 | } |
602 | 602 | } |
603 | - else{ |
|
604 | - if(isset($this->inputs[$key])){ |
|
603 | + else { |
|
604 | + if (isset($this->inputs[$key])) { |
|
605 | 605 | $keyMethod = $this->{$method}(); |
606 | 606 | $this->inputs[$key] = $keyMethod; |
607 | 607 | } |
@@ -620,8 +620,8 @@ discard block |
||
620 | 620 | // the auto object validate property is the property |
621 | 621 | // where all of your request values are automatically validated. |
622 | 622 | /** @noinspection PhpParamsInspection */ |
623 | - if(property_exists($this,'autoObjectValidate') |
|
624 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
623 | + if (property_exists($this, 'autoObjectValidate') |
|
624 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
625 | 625 | $this->autoValidate('autoObjectValidate'); |
626 | 626 | } |
627 | 627 | } |