@@ -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,26 +130,26 @@ 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 | 145 | $caret = $this->capsuleCaret(); |
146 | 146 | |
147 | - foreach($this->inputs as $input=>$value){ |
|
147 | + foreach ($this->inputs as $input=>$value) { |
|
148 | 148 | |
149 | - if(isset($caret[$input]) || ( |
|
150 | - $this->checkProperties('capsule') && !in_array($input,$this->capsule) |
|
151 | - )){ |
|
152 | - exception('clientCapsule',['key'=>$input]) |
|
149 | + if (isset($caret[$input]) || ( |
|
150 | + $this->checkProperties('capsule') && !in_array($input, $this->capsule) |
|
151 | + )) { |
|
152 | + exception('clientCapsule', ['key'=>$input]) |
|
153 | 153 | ->overflow('The '.$input.' value cannot be sent.'); |
154 | 154 | } |
155 | 155 | } |
@@ -165,15 +165,15 @@ discard block |
||
165 | 165 | { |
166 | 166 | $caret = []; |
167 | 167 | |
168 | - foreach($this->inputs as $input=>$item){ |
|
169 | - if(in_array('@'.$input,$this->capsule)){ |
|
168 | + foreach ($this->inputs as $input=>$item) { |
|
169 | + if (in_array('@'.$input, $this->capsule)) { |
|
170 | 170 | $caret[$input] = $item; |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | 174 | foreach ($this->capsule as $item) { |
175 | - if(preg_match('#@.*#is',$item)){ |
|
176 | - $this->capsule = array_diff($this->capsule,[$item]); |
|
175 | + if (preg_match('#@.*#is', $item)) { |
|
176 | + $this->capsule = array_diff($this->capsule, [$item]); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
@@ -192,15 +192,15 @@ discard block |
||
192 | 192 | |
193 | 193 | // Determines which HTTP method |
194 | 194 | // the request object will be exposed to. |
195 | - if($this->checkProperties('http')){ |
|
195 | + if ($this->checkProperties('http')) { |
|
196 | 196 | |
197 | 197 | // if the current http method does not exist |
198 | 198 | // in the http object, the exception will be thrown. |
199 | - if(!in_array($method,$this->http)){ |
|
199 | + if (!in_array($method, $this->http)) { |
|
200 | 200 | |
201 | 201 | //exception batMethodCall |
202 | 202 | exception()->badMethodCall( |
203 | - 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
203 | + 'Invalid http method process for '.basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | { |
216 | 216 | // from the properties of the object properties to |
217 | 217 | // the existing variables, control the array and at least one element. |
218 | - return (property_exists($this,$properties) |
|
218 | + return (property_exists($this, $properties) |
|
219 | 219 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
220 | 220 | } |
221 | 221 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | // we are saving the expected values for the request in container. |
230 | 230 | // this record can be returned in exception information. |
231 | - app()->register('requestExpected',$this->expected); |
|
231 | + app()->register('requestExpected', $this->expected); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -240,15 +240,15 @@ discard block |
||
240 | 240 | public function except($except) |
241 | 241 | { |
242 | 242 | // the except parameter is a callable value. |
243 | - if(is_callable($except)){ |
|
244 | - $call = call_user_func_array($except,[$this]); |
|
243 | + if (is_callable($except)) { |
|
244 | + $call = call_user_func_array($except, [$this]); |
|
245 | 245 | $except = $call; |
246 | 246 | } |
247 | 247 | |
248 | 248 | // except with the except exceptions property |
249 | 249 | // and then assigning them to the inputs property. |
250 | - $this->except = array_merge($this->except,$except); |
|
251 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
250 | + $this->except = array_merge($this->except, $except); |
|
251 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
252 | 252 | |
253 | 253 | return $this; |
254 | 254 | } |
@@ -262,27 +262,27 @@ discard block |
||
262 | 262 | { |
263 | 263 | // expected method is executed. |
264 | 264 | // this method is a must for http method values to be found in this property. |
265 | - if($this->checkProperties('expected')){ |
|
265 | + if ($this->checkProperties('expected')) { |
|
266 | 266 | |
267 | 267 | // if the expected values are not found in the inputs array, |
268 | 268 | // the exception will be thrown. |
269 | - foreach ($this->expected as $expected){ |
|
269 | + foreach ($this->expected as $expected) { |
|
270 | 270 | |
271 | 271 | $expectedValues = []; |
272 | 272 | |
273 | 273 | // mandatory expected data for each key can be separated by | operator. |
274 | 274 | // this is evaluated as "or". |
275 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
276 | - if(!isset($this->inputs[$inputs])){ |
|
275 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
276 | + if (!isset($this->inputs[$inputs])) { |
|
277 | 277 | $expectedValues[] = $inputs; |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | 281 | // if the expectedData and expectedValues |
282 | 282 | // array are numerically equal to the expected key, the exception is thrown. |
283 | - if(count($expectedData)===count($expectedValues)){ |
|
284 | - exception('clientExpected',['key'=>$expected]) |
|
285 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
283 | + if (count($expectedData)===count($expectedValues)) { |
|
284 | + exception('clientExpected', ['key'=>$expected]) |
|
285 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | } |
@@ -297,17 +297,17 @@ discard block |
||
297 | 297 | { |
298 | 298 | // check the presence of the generator object |
299 | 299 | // and operate the generator over this object. |
300 | - if($this->checkProperties('auto_generators')){ |
|
300 | + if ($this->checkProperties('auto_generators')) { |
|
301 | 301 | $generators = $this->getAutoGenerators(); |
302 | 302 | } |
303 | 303 | |
304 | 304 | // check the presence of the generator object |
305 | 305 | // and operate the generator over this object. |
306 | - if($this->checkProperties('generators')){ |
|
307 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
306 | + if ($this->checkProperties('generators')) { |
|
307 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
308 | 308 | } |
309 | 309 | |
310 | - if(isset($generators)){ |
|
310 | + if (isset($generators)) { |
|
311 | 311 | $this->generatorMethod($generators); |
312 | 312 | } |
313 | 313 | } |
@@ -322,21 +322,21 @@ discard block |
||
322 | 322 | private function generatorMethod($generators) |
323 | 323 | { |
324 | 324 | //generator array object |
325 | - foreach ($generators as $generator){ |
|
325 | + foreach ($generators as $generator) { |
|
326 | 326 | |
327 | 327 | //generator method name |
328 | 328 | $generatorMethodName = $generator.'Generator'; |
329 | 329 | |
330 | 330 | // if the generator method is present, |
331 | 331 | // the fake value is assigned. |
332 | - if(method_exists($this,$generatorMethodName)){ |
|
332 | + if (method_exists($this, $generatorMethodName)) { |
|
333 | 333 | |
334 | 334 | //fake registration |
335 | - if(!isset($this->inputs[$generator])){ |
|
335 | + if (!isset($this->inputs[$generator])) { |
|
336 | 336 | |
337 | 337 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
338 | 338 | |
339 | - if(!is_null($generatorMethodNameResult)){ |
|
339 | + if (!is_null($generatorMethodNameResult)) { |
|
340 | 340 | $this->{$generator} = $this->{$generatorMethodName}(); |
341 | 341 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
342 | 342 | $this->generatorList[] = $generator; |
@@ -344,15 +344,15 @@ discard block |
||
344 | 344 | } |
345 | 345 | else { |
346 | 346 | |
347 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
348 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
347 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
348 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
349 | 349 | $this->{$generator} = $this->{$generatorMethodName}(); |
350 | 350 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
351 | 351 | $this->generatorList[] = $generator; |
352 | 352 | } |
353 | 353 | |
354 | - if($this->checkProperties('generators_dont_overwrite') |
|
355 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
354 | + if ($this->checkProperties('generators_dont_overwrite') |
|
355 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
356 | 356 | $this->{$generator} = $this->{$generatorMethodName}(); |
357 | 357 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
358 | 358 | $this->generatorList[] = $generator; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | { |
416 | 416 | // we use the http method to write |
417 | 417 | // the values to the inputs and origin properties. |
418 | - foreach($this->clientData as $key=>$value){ |
|
418 | + foreach ($this->clientData as $key=>$value) { |
|
419 | 419 | |
420 | 420 | //inputs and origin properties |
421 | 421 | $this->inputs[$key] = $value; |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | */ |
432 | 432 | private function requestExcept() |
433 | 433 | { |
434 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
435 | - foreach ($this->requestExcept as $item){ |
|
436 | - if(isset($this->inputs[$item])){ |
|
434 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
435 | + foreach ($this->requestExcept as $item) { |
|
436 | + if (isset($this->inputs[$item])) { |
|
437 | 437 | unset($this->inputs[$item]); |
438 | 438 | } |
439 | 439 | } |
@@ -473,16 +473,16 @@ discard block |
||
473 | 473 | * @param null|string $clientName |
474 | 474 | * @return void|mixed |
475 | 475 | */ |
476 | - public function setClientName($clientName=null) |
|
476 | + public function setClientName($clientName = null) |
|
477 | 477 | { |
478 | - if(!is_null($clientName) && is_string($clientName)){ |
|
478 | + if (!is_null($clientName) && is_string($clientName)) { |
|
479 | 479 | return $this->clientName = $clientName; |
480 | 480 | } |
481 | 481 | |
482 | - if(!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])){ |
|
482 | + if (!is_null(Utils::trace(0)) && isset(Utils::trace(0)['object'])) { |
|
483 | 483 | $backTrace = Utils::trace(0)['object']; |
484 | 484 | |
485 | - if(property_exists($backTrace,'clientName')){ |
|
485 | + if (property_exists($backTrace, 'clientName')) { |
|
486 | 486 | $this->clientName = $backTrace->clientName; |
487 | 487 | } |
488 | 488 | } |
@@ -499,9 +499,9 @@ discard block |
||
499 | 499 | |
500 | 500 | // we update the input values after |
501 | 501 | // we receive and check the saved objects. |
502 | - foreach ($clientObjects as $key=>$value){ |
|
502 | + foreach ($clientObjects as $key=>$value) { |
|
503 | 503 | |
504 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
504 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
505 | 505 | |
506 | 506 | $this->{$key} = $clientObjects['origin'][$key]; |
507 | 507 | $this->inputs[$key] = $this->{$key}; |
@@ -529,11 +529,11 @@ discard block |
||
529 | 529 | |
530 | 530 | // the request update to be performed using |
531 | 531 | // the method name to be used with the http method. |
532 | - $this->setRequestInputs($requestMethod,$key); |
|
532 | + $this->setRequestInputs($requestMethod, $key); |
|
533 | 533 | |
534 | 534 | // the request update to be performed using |
535 | 535 | // the method name to be used without the http method. |
536 | - $this->setRequestInputs($key,$key); |
|
536 | + $this->setRequestInputs($key, $key); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
@@ -544,28 +544,28 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @throws ReflectionExceptionAlias |
546 | 546 | */ |
547 | - private function setRequestInputs($method,$key) |
|
547 | + private function setRequestInputs($method, $key) |
|
548 | 548 | { |
549 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
549 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
550 | 550 | |
551 | 551 | //check annotations for method |
552 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
553 | - $annotation->annotation($method,$key); |
|
552 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
553 | + $annotation->annotation($method, $key); |
|
554 | 554 | |
555 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
555 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
556 | 556 | |
557 | 557 | $inputKeys = $this->inputs[$key]; |
558 | 558 | |
559 | 559 | $this->inputs[$key] = []; |
560 | - foreach ($inputKeys as $input){ |
|
560 | + foreach ($inputKeys as $input) { |
|
561 | 561 | |
562 | 562 | $this->{$key} = $input; |
563 | 563 | $keyMethod = $this->{$method}(); |
564 | 564 | $this->inputs[$key][] = $keyMethod; |
565 | 565 | } |
566 | 566 | } |
567 | - else{ |
|
568 | - if(isset($this->inputs[$key])){ |
|
567 | + else { |
|
568 | + if (isset($this->inputs[$key])) { |
|
569 | 569 | $keyMethod = $this->{$method}(); |
570 | 570 | $this->inputs[$key] = $keyMethod; |
571 | 571 | } |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | // the auto object validate property is the property |
585 | 585 | // where all of your request values are automatically validated. |
586 | 586 | /** @noinspection PhpParamsInspection */ |
587 | - if(property_exists($this,'autoObjectValidate') |
|
588 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
587 | + if (property_exists($this, 'autoObjectValidate') |
|
588 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
589 | 589 | $this->autoValidate('autoObjectValidate'); |
590 | 590 | } |
591 | 591 | } |