@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @throws ReflectionExceptionAlias |
63 | 63 | */ |
64 | - public function __construct($clientData=null) |
|
64 | + public function __construct($clientData = null) |
|
65 | 65 | { |
66 | 66 | //reflection process |
67 | 67 | $this->reflection = app()['reflection']($this); |
68 | 68 | |
69 | - if(property_exists(debug_backtrace()[0]['object'],'clientName')){ |
|
69 | + if (property_exists(debug_backtrace()[0]['object'], 'clientName')) { |
|
70 | 70 | $this->clientName = debug_backtrace()[0]['object']->clientName; |
71 | 71 | } |
72 | 72 | |
73 | 73 | //get http method via request http manager class |
74 | - $this->requestHttp = app()->resolve(ClientHttpManager::class,['client'=>$this]); |
|
74 | + $this->requestHttp = app()->resolve(ClientHttpManager::class, ['client'=>$this]); |
|
75 | 75 | |
76 | 76 | //get request client data |
77 | 77 | $this->clientData = ($clientData===null) ? $this->requestHttp->resolve() : $clientData; |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | private function autoValidate($validate) |
89 | 89 | { |
90 | 90 | //we get the values to auto-validate. |
91 | - foreach ($this->{$validate} as $object=>$datas){ |
|
91 | + foreach ($this->{$validate} as $object=>$datas) { |
|
92 | 92 | |
93 | 93 | // the auto-validate value must necessarily represent a class. |
94 | 94 | // otherwise auto-validate is not used. |
95 | - if(Utils::isNamespaceExists($object)){ |
|
95 | + if (Utils::isNamespaceExists($object)) { |
|
96 | 96 | $getObjectInstance = app()->resolve($object); |
97 | 97 | |
98 | 98 | // we get the index values, |
99 | 99 | // which are called methods of the auto-validate value that represents the class. |
100 | - foreach ($datas as $dataKey=>$data){ |
|
100 | + foreach ($datas as $dataKey=>$data) { |
|
101 | 101 | |
102 | 102 | // if the methods of the auto-validate class resolved by the container resolve method apply, |
103 | 103 | // the process of auto-validate automatic implementation will be completed. |
104 | - if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){ |
|
105 | - if(isset($this->origin[$data])){ |
|
106 | - if(!is_array($this->origin[$data])){ |
|
104 | + if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) { |
|
105 | + if (isset($this->origin[$data])) { |
|
106 | + if (!is_array($this->origin[$data])) { |
|
107 | 107 | $this->origin[$data] = array($this->origin[$data]); |
108 | 108 | } |
109 | - foreach ($this->origin[$data] as $originData){ |
|
109 | + foreach ($this->origin[$data] as $originData) { |
|
110 | 110 | $getObjectInstance->{$data}($originData); |
111 | 111 | } |
112 | 112 | } |
@@ -123,26 +123,26 @@ discard block |
||
123 | 123 | */ |
124 | 124 | private function capsule() |
125 | 125 | { |
126 | - if(method_exists($this,'capsuleMethod')){ |
|
127 | - $this->capsule = array_merge($this->capsule,$this->capsuleMethod()); |
|
126 | + if (method_exists($this, 'capsuleMethod')) { |
|
127 | + $this->capsule = array_merge($this->capsule, $this->capsuleMethod()); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // expected method is executed. |
131 | 131 | // this method is a must for http method values to be found in this property. |
132 | - if($this->checkProperties('capsule')){ |
|
132 | + if ($this->checkProperties('capsule')) { |
|
133 | 133 | |
134 | - if(property_exists($this,'auto_capsule') && is_array($this->auto_capsule)){ |
|
135 | - $this->capsule = array_merge($this->capsule,$this->auto_capsule); |
|
134 | + if (property_exists($this, 'auto_capsule') && is_array($this->auto_capsule)) { |
|
135 | + $this->capsule = array_merge($this->capsule, $this->auto_capsule); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | $caret = $this->capsuleCaret(); |
139 | 139 | |
140 | - foreach($this->inputs as $input=>$value){ |
|
140 | + foreach ($this->inputs as $input=>$value) { |
|
141 | 141 | |
142 | - if(isset($caret[$input]) || ( |
|
143 | - $this->checkProperties('capsule') && !in_array($input,$this->capsule) |
|
144 | - )){ |
|
145 | - exception('clientCapsule',['key'=>$input]) |
|
142 | + if (isset($caret[$input]) || ( |
|
143 | + $this->checkProperties('capsule') && !in_array($input, $this->capsule) |
|
144 | + )) { |
|
145 | + exception('clientCapsule', ['key'=>$input]) |
|
146 | 146 | ->overflow('The '.$input.' value cannot be sent.'); |
147 | 147 | } |
148 | 148 | } |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | { |
159 | 159 | $caret = []; |
160 | 160 | |
161 | - foreach($this->inputs as $input=>$item){ |
|
162 | - if(in_array('@'.$input,$this->capsule)){ |
|
161 | + foreach ($this->inputs as $input=>$item) { |
|
162 | + if (in_array('@'.$input, $this->capsule)) { |
|
163 | 163 | $caret[$input] = $item; |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | 167 | foreach ($this->capsule as $item) { |
168 | - if(preg_match('#@.*#is',$item)){ |
|
169 | - $this->capsule = array_diff($this->capsule,[$item]); |
|
168 | + if (preg_match('#@.*#is', $item)) { |
|
169 | + $this->capsule = array_diff($this->capsule, [$item]); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | |
186 | 186 | // Determines which HTTP method |
187 | 187 | // the request object will be exposed to. |
188 | - if($this->checkProperties('http')){ |
|
188 | + if ($this->checkProperties('http')) { |
|
189 | 189 | |
190 | 190 | // if the current http method does not exist |
191 | 191 | // in the http object, the exception will be thrown. |
192 | - if(!in_array($method,$this->http)){ |
|
192 | + if (!in_array($method, $this->http)) { |
|
193 | 193 | |
194 | 194 | //exception batMethodCall |
195 | 195 | exception()->badMethodCall( |
196 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
196 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | // from the properties of the object properties to |
210 | 210 | // the existing variables, control the array and at least one element. |
211 | - return (property_exists($this,$properties) |
|
211 | + return (property_exists($this, $properties) |
|
212 | 212 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
213 | 213 | } |
214 | 214 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | { |
222 | 222 | // we are saving the expected values for the request in container. |
223 | 223 | // this record can be returned in exception information. |
224 | - app()->register('requestExpected',$this->expected); |
|
224 | + app()->register('requestExpected', $this->expected); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | public function except($except) |
234 | 234 | { |
235 | 235 | // the except parameter is a callable value. |
236 | - if(is_callable($except)){ |
|
237 | - $call = call_user_func_array($except,[$this]); |
|
236 | + if (is_callable($except)) { |
|
237 | + $call = call_user_func_array($except, [$this]); |
|
238 | 238 | $except = $call; |
239 | 239 | } |
240 | 240 | |
241 | 241 | // except with the except exceptions property |
242 | 242 | // and then assigning them to the inputs property. |
243 | - $this->except = array_merge($this->except,$except); |
|
244 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
243 | + $this->except = array_merge($this->except, $except); |
|
244 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
245 | 245 | |
246 | 246 | return $this; |
247 | 247 | } |
@@ -255,27 +255,27 @@ discard block |
||
255 | 255 | { |
256 | 256 | // expected method is executed. |
257 | 257 | // this method is a must for http method values to be found in this property. |
258 | - if($this->checkProperties('expected')){ |
|
258 | + if ($this->checkProperties('expected')) { |
|
259 | 259 | |
260 | 260 | // if the expected values are not found in the inputs array, |
261 | 261 | // the exception will be thrown. |
262 | - foreach ($this->expected as $expected){ |
|
262 | + foreach ($this->expected as $expected) { |
|
263 | 263 | |
264 | 264 | $expectedValues = []; |
265 | 265 | |
266 | 266 | // mandatory expected data for each key can be separated by | operator. |
267 | 267 | // this is evaluated as "or". |
268 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
269 | - if(!isset($this->inputs[$inputs])){ |
|
268 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
269 | + if (!isset($this->inputs[$inputs])) { |
|
270 | 270 | $expectedValues[] = $inputs; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | 274 | // if the expectedData and expectedValues |
275 | 275 | // array are numerically equal to the expected key, the exception is thrown. |
276 | - if(count($expectedData)===count($expectedValues)){ |
|
277 | - exception('clientExpected',['key'=>$expected]) |
|
278 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
276 | + if (count($expectedData)===count($expectedValues)) { |
|
277 | + exception('clientExpected', ['key'=>$expected]) |
|
278 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | } |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | { |
291 | 291 | // check the presence of the generator object |
292 | 292 | // and operate the generator over this object. |
293 | - if($this->checkProperties('auto_generators')){ |
|
293 | + if ($this->checkProperties('auto_generators')) { |
|
294 | 294 | $generators = $this->getAutoGenerators(); |
295 | 295 | } |
296 | 296 | |
297 | 297 | // check the presence of the generator object |
298 | 298 | // and operate the generator over this object. |
299 | - if($this->checkProperties('generators')){ |
|
300 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
299 | + if ($this->checkProperties('generators')) { |
|
300 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
301 | 301 | } |
302 | 302 | |
303 | - if(isset($generators)){ |
|
303 | + if (isset($generators)) { |
|
304 | 304 | $this->generatorMethod($generators); |
305 | 305 | } |
306 | 306 | } |
@@ -315,21 +315,21 @@ discard block |
||
315 | 315 | private function generatorMethod($generators) |
316 | 316 | { |
317 | 317 | //generator array object |
318 | - foreach ($generators as $generator){ |
|
318 | + foreach ($generators as $generator) { |
|
319 | 319 | |
320 | 320 | //generator method name |
321 | 321 | $generatorMethodName = $generator.'Generator'; |
322 | 322 | |
323 | 323 | // if the generator method is present, |
324 | 324 | // the fake value is assigned. |
325 | - if(method_exists($this,$generatorMethodName)){ |
|
325 | + if (method_exists($this, $generatorMethodName)) { |
|
326 | 326 | |
327 | 327 | //fake registration |
328 | - if(!isset($this->inputs[$generator])){ |
|
328 | + if (!isset($this->inputs[$generator])) { |
|
329 | 329 | |
330 | 330 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
331 | 331 | |
332 | - if(!is_null($generatorMethodNameResult)){ |
|
332 | + if (!is_null($generatorMethodNameResult)) { |
|
333 | 333 | $this->{$generator} = $this->{$generatorMethodName}(); |
334 | 334 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
335 | 335 | $this->generatorList[] = $generator; |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | } |
338 | 338 | else { |
339 | 339 | |
340 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
341 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
340 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
341 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
342 | 342 | $this->{$generator} = $this->{$generatorMethodName}(); |
343 | 343 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
344 | 344 | $this->generatorList[] = $generator; |
345 | 345 | } |
346 | 346 | |
347 | - if($this->checkProperties('generators_dont_overwrite') |
|
348 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
347 | + if ($this->checkProperties('generators_dont_overwrite') |
|
348 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
349 | 349 | $this->{$generator} = $this->{$generatorMethodName}(); |
350 | 350 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
351 | 351 | $this->generatorList[] = $generator; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | { |
409 | 409 | // we use the http method to write |
410 | 410 | // the values to the inputs and origin properties. |
411 | - foreach($this->clientData as $key=>$value){ |
|
411 | + foreach ($this->clientData as $key=>$value) { |
|
412 | 412 | |
413 | 413 | //inputs and origin properties |
414 | 414 | $this->inputs[$key] = $value; |
@@ -424,9 +424,9 @@ discard block |
||
424 | 424 | */ |
425 | 425 | private function requestExcept() |
426 | 426 | { |
427 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
428 | - foreach ($this->requestExcept as $item){ |
|
429 | - if(isset($this->inputs[$item])){ |
|
427 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
428 | + foreach ($this->requestExcept as $item) { |
|
429 | + if (isset($this->inputs[$item])) { |
|
430 | 430 | unset($this->inputs[$item]); |
431 | 431 | } |
432 | 432 | } |
@@ -471,9 +471,9 @@ discard block |
||
471 | 471 | |
472 | 472 | // we update the input values after |
473 | 473 | // we receive and check the saved objects. |
474 | - foreach ($clientObjects as $key=>$value){ |
|
474 | + foreach ($clientObjects as $key=>$value) { |
|
475 | 475 | |
476 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
476 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
477 | 477 | |
478 | 478 | $this->{$key} = $clientObjects['origin'][$key]; |
479 | 479 | $this->inputs[$key] = $this->{$key}; |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | |
502 | 502 | // the request update to be performed using |
503 | 503 | // the method name to be used with the http method. |
504 | - $this->setRequestInputs($requestMethod,$key); |
|
504 | + $this->setRequestInputs($requestMethod, $key); |
|
505 | 505 | |
506 | 506 | // the request update to be performed using |
507 | 507 | // the method name to be used without the http method. |
508 | - $this->setRequestInputs($key,$key); |
|
508 | + $this->setRequestInputs($key, $key); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
@@ -516,28 +516,28 @@ discard block |
||
516 | 516 | * |
517 | 517 | * @throws ReflectionExceptionAlias |
518 | 518 | */ |
519 | - private function setRequestInputs($method,$key) |
|
519 | + private function setRequestInputs($method, $key) |
|
520 | 520 | { |
521 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
521 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
522 | 522 | |
523 | 523 | //check annotations for method |
524 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
525 | - $annotation->annotation($method,$key); |
|
524 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
525 | + $annotation->annotation($method, $key); |
|
526 | 526 | |
527 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
527 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
528 | 528 | |
529 | 529 | $inputKeys = $this->inputs[$key]; |
530 | 530 | |
531 | 531 | $this->inputs[$key] = []; |
532 | - foreach ($inputKeys as $input){ |
|
532 | + foreach ($inputKeys as $input) { |
|
533 | 533 | |
534 | 534 | $this->{$key} = $input; |
535 | 535 | $keyMethod = $this->{$method}(); |
536 | 536 | $this->inputs[$key][] = $keyMethod; |
537 | 537 | } |
538 | 538 | } |
539 | - else{ |
|
540 | - if(isset($this->inputs[$key])){ |
|
539 | + else { |
|
540 | + if (isset($this->inputs[$key])) { |
|
541 | 541 | $keyMethod = $this->{$method}(); |
542 | 542 | $this->inputs[$key] = $keyMethod; |
543 | 543 | } |
@@ -555,8 +555,8 @@ discard block |
||
555 | 555 | { |
556 | 556 | // the auto object validate property is the property |
557 | 557 | // where all of your request values are automatically validated. |
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 | } |