@@ -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 | } |
@@ -125,19 +125,19 @@ discard block |
||
125 | 125 | { |
126 | 126 | // expected method is executed. |
127 | 127 | // this method is a must for http method values to be found in this property. |
128 | - if($this->checkProperties('capsule')){ |
|
128 | + if ($this->checkProperties('capsule')) { |
|
129 | 129 | |
130 | - if(property_exists($this,'auto_capsule') && is_array($this->auto_capsule)){ |
|
131 | - $this->capsule = array_merge($this->capsule,$this->auto_capsule); |
|
130 | + if (property_exists($this, 'auto_capsule') && is_array($this->auto_capsule)) { |
|
131 | + $this->capsule = array_merge($this->capsule, $this->auto_capsule); |
|
132 | 132 | } |
133 | 133 | $caret = $this->capsuleCaret(); |
134 | 134 | |
135 | - foreach($this->inputs as $input=>$value){ |
|
135 | + foreach ($this->inputs as $input=>$value) { |
|
136 | 136 | |
137 | - if(isset($caret[$input]) || ( |
|
138 | - $this->checkProperties('capsule') && !in_array($input,$this->capsule) |
|
139 | - )){ |
|
140 | - exception('clientCapsule',['key'=>$input]) |
|
137 | + if (isset($caret[$input]) || ( |
|
138 | + $this->checkProperties('capsule') && !in_array($input, $this->capsule) |
|
139 | + )) { |
|
140 | + exception('clientCapsule', ['key'=>$input]) |
|
141 | 141 | ->overflow('The '.$input.' value cannot be sent.'); |
142 | 142 | } |
143 | 143 | } |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | { |
154 | 154 | $caret = []; |
155 | 155 | |
156 | - foreach($this->inputs as $input=>$item){ |
|
157 | - if(in_array('@'.$input,$this->capsule)){ |
|
156 | + foreach ($this->inputs as $input=>$item) { |
|
157 | + if (in_array('@'.$input, $this->capsule)) { |
|
158 | 158 | $caret[$input] = $item; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | 162 | foreach ($this->capsule as $item) { |
163 | - if(preg_match('#@.*#is',$item)){ |
|
164 | - $this->capsule = array_diff($this->capsule,[$item]); |
|
163 | + if (preg_match('#@.*#is', $item)) { |
|
164 | + $this->capsule = array_diff($this->capsule, [$item]); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | |
181 | 181 | // Determines which HTTP method |
182 | 182 | // the request object will be exposed to. |
183 | - if($this->checkProperties('http')){ |
|
183 | + if ($this->checkProperties('http')) { |
|
184 | 184 | |
185 | 185 | // if the current http method does not exist |
186 | 186 | // in the http object, the exception will be thrown. |
187 | - if(!in_array($method,$this->http)){ |
|
187 | + if (!in_array($method, $this->http)) { |
|
188 | 188 | |
189 | 189 | //exception batMethodCall |
190 | 190 | exception()->badMethodCall( |
191 | - 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] '); |
|
191 | + 'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] '); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | // from the properties of the object properties to |
205 | 205 | // the existing variables, control the array and at least one element. |
206 | - return (property_exists($this,$properties) |
|
206 | + return (property_exists($this, $properties) |
|
207 | 207 | && is_array($this->{$properties}) && count($this->{$properties})) ? true : false; |
208 | 208 | } |
209 | 209 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | // we are saving the expected values for the request in container. |
218 | 218 | // this record can be returned in exception information. |
219 | - app()->register('requestExpected',$this->expected); |
|
219 | + app()->register('requestExpected', $this->expected); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | public function except($except) |
229 | 229 | { |
230 | 230 | // the except parameter is a callable value. |
231 | - if(is_callable($except)){ |
|
232 | - $call = call_user_func_array($except,[$this]); |
|
231 | + if (is_callable($except)) { |
|
232 | + $call = call_user_func_array($except, [$this]); |
|
233 | 233 | $except = $call; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // except with the except exceptions property |
237 | 237 | // and then assigning them to the inputs property. |
238 | - $this->except = array_merge($this->except,$except); |
|
239 | - $this->inputs = array_diff_key($this->inputs,array_flip($this->except)); |
|
238 | + $this->except = array_merge($this->except, $except); |
|
239 | + $this->inputs = array_diff_key($this->inputs, array_flip($this->except)); |
|
240 | 240 | |
241 | 241 | return $this; |
242 | 242 | } |
@@ -250,27 +250,27 @@ discard block |
||
250 | 250 | { |
251 | 251 | // expected method is executed. |
252 | 252 | // this method is a must for http method values to be found in this property. |
253 | - if($this->checkProperties('expected')){ |
|
253 | + if ($this->checkProperties('expected')) { |
|
254 | 254 | |
255 | 255 | // if the expected values are not found in the inputs array, |
256 | 256 | // the exception will be thrown. |
257 | - foreach ($this->expected as $expected){ |
|
257 | + foreach ($this->expected as $expected) { |
|
258 | 258 | |
259 | 259 | $expectedValues = []; |
260 | 260 | |
261 | 261 | // mandatory expected data for each key can be separated by | operator. |
262 | 262 | // this is evaluated as "or". |
263 | - foreach($expectedData = explode("|",$expected) as $inputs){ |
|
264 | - if(!isset($this->inputs[$inputs])){ |
|
263 | + foreach ($expectedData = explode("|", $expected) as $inputs) { |
|
264 | + if (!isset($this->inputs[$inputs])) { |
|
265 | 265 | $expectedValues[] = $inputs; |
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | 269 | // if the expectedData and expectedValues |
270 | 270 | // array are numerically equal to the expected key, the exception is thrown. |
271 | - if(count($expectedData)===count($expectedValues)){ |
|
272 | - exception('clientExpected',['key'=>$expected]) |
|
273 | - ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object'); |
|
271 | + if (count($expectedData)===count($expectedValues)) { |
|
272 | + exception('clientExpected', ['key'=>$expected]) |
|
273 | + ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object'); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
@@ -285,17 +285,17 @@ discard block |
||
285 | 285 | { |
286 | 286 | // check the presence of the generator object |
287 | 287 | // and operate the generator over this object. |
288 | - if($this->checkProperties('auto_generators')){ |
|
288 | + if ($this->checkProperties('auto_generators')) { |
|
289 | 289 | $generators = $this->getAutoGenerators(); |
290 | 290 | } |
291 | 291 | |
292 | 292 | // check the presence of the generator object |
293 | 293 | // and operate the generator over this object. |
294 | - if($this->checkProperties('generators')){ |
|
295 | - $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators()); |
|
294 | + if ($this->checkProperties('generators')) { |
|
295 | + $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators()); |
|
296 | 296 | } |
297 | 297 | |
298 | - if(isset($generators)){ |
|
298 | + if (isset($generators)) { |
|
299 | 299 | $this->generatorMethod($generators); |
300 | 300 | } |
301 | 301 | } |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | private function generatorMethod($generators) |
311 | 311 | { |
312 | 312 | //generator array object |
313 | - foreach ($generators as $generator){ |
|
313 | + foreach ($generators as $generator) { |
|
314 | 314 | |
315 | 315 | //generator method name |
316 | 316 | $generatorMethodName = $generator.'Generator'; |
317 | 317 | |
318 | 318 | // if the generator method is present, |
319 | 319 | // the fake value is assigned. |
320 | - if(method_exists($this,$generatorMethodName)){ |
|
320 | + if (method_exists($this, $generatorMethodName)) { |
|
321 | 321 | |
322 | 322 | //fake registration |
323 | - if(!isset($this->inputs[$generator])){ |
|
323 | + if (!isset($this->inputs[$generator])) { |
|
324 | 324 | |
325 | 325 | $generatorMethodNameResult = $this->{$generatorMethodName}(); |
326 | 326 | |
327 | - if(!is_null($generatorMethodNameResult)){ |
|
327 | + if (!is_null($generatorMethodNameResult)) { |
|
328 | 328 | $this->{$generator} = $this->{$generatorMethodName}(); |
329 | 329 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
330 | 330 | $this->generatorList[] = $generator; |
@@ -332,15 +332,15 @@ discard block |
||
332 | 332 | } |
333 | 333 | else { |
334 | 334 | |
335 | - if($this->checkProperties('auto_generators_dont_overwrite') |
|
336 | - && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){ |
|
335 | + if ($this->checkProperties('auto_generators_dont_overwrite') |
|
336 | + && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) { |
|
337 | 337 | $this->{$generator} = $this->{$generatorMethodName}(); |
338 | 338 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
339 | 339 | $this->generatorList[] = $generator; |
340 | 340 | } |
341 | 341 | |
342 | - if($this->checkProperties('generators_dont_overwrite') |
|
343 | - && in_array($generator,$this->getGeneratorsDontOverwrite())){ |
|
342 | + if ($this->checkProperties('generators_dont_overwrite') |
|
343 | + && in_array($generator, $this->getGeneratorsDontOverwrite())) { |
|
344 | 344 | $this->{$generator} = $this->{$generatorMethodName}(); |
345 | 345 | $this->inputs[$generator] = $this->{$generatorMethodName}(); |
346 | 346 | $this->generatorList[] = $generator; |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | { |
404 | 404 | // we use the http method to write |
405 | 405 | // the values to the inputs and origin properties. |
406 | - foreach($this->clientData as $key=>$value){ |
|
406 | + foreach ($this->clientData as $key=>$value) { |
|
407 | 407 | |
408 | 408 | //inputs and origin properties |
409 | 409 | $this->inputs[$key] = $value; |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | */ |
420 | 420 | private function requestExcept() |
421 | 421 | { |
422 | - if(property_exists($this,'requestExcept') && is_array($this->requestExcept)){ |
|
423 | - foreach ($this->requestExcept as $item){ |
|
424 | - if(isset($this->inputs[$item])){ |
|
422 | + if (property_exists($this, 'requestExcept') && is_array($this->requestExcept)) { |
|
423 | + foreach ($this->requestExcept as $item) { |
|
424 | + if (isset($this->inputs[$item])) { |
|
425 | 425 | unset($this->inputs[$item]); |
426 | 426 | } |
427 | 427 | } |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | |
467 | 467 | // we update the input values after |
468 | 468 | // we receive and check the saved objects. |
469 | - foreach ($clientObjects as $key=>$value){ |
|
469 | + foreach ($clientObjects as $key=>$value) { |
|
470 | 470 | |
471 | - if(!in_array($key,$this->generatorList) && isset($clientObjects['origin'][$key])){ |
|
471 | + if (!in_array($key, $this->generatorList) && isset($clientObjects['origin'][$key])) { |
|
472 | 472 | |
473 | 473 | $this->{$key} = $clientObjects['origin'][$key]; |
474 | 474 | $this->inputs[$key] = $this->{$key}; |
@@ -496,11 +496,11 @@ discard block |
||
496 | 496 | |
497 | 497 | // the request update to be performed using |
498 | 498 | // the method name to be used with the http method. |
499 | - $this->setRequestInputs($requestMethod,$key); |
|
499 | + $this->setRequestInputs($requestMethod, $key); |
|
500 | 500 | |
501 | 501 | // the request update to be performed using |
502 | 502 | // the method name to be used without the http method. |
503 | - $this->setRequestInputs($key,$key); |
|
503 | + $this->setRequestInputs($key, $key); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -511,28 +511,28 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @throws ReflectionExceptionAlias |
513 | 513 | */ |
514 | - private function setRequestInputs($method,$key) |
|
514 | + private function setRequestInputs($method, $key) |
|
515 | 515 | { |
516 | - if(!in_array($key,$this->generatorList) && method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){ |
|
516 | + if (!in_array($key, $this->generatorList) && method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) { |
|
517 | 517 | |
518 | 518 | //check annotations for method |
519 | - $annotation = app()->resolve(ClientAnnotationManager::class,['request'=>$this]); |
|
520 | - $annotation->annotation($method,$key); |
|
519 | + $annotation = app()->resolve(ClientAnnotationManager::class, ['request'=>$this]); |
|
520 | + $annotation->annotation($method, $key); |
|
521 | 521 | |
522 | - if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){ |
|
522 | + if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) { |
|
523 | 523 | |
524 | 524 | $inputKeys = $this->inputs[$key]; |
525 | 525 | |
526 | 526 | $this->inputs[$key] = []; |
527 | - foreach ($inputKeys as $input){ |
|
527 | + foreach ($inputKeys as $input) { |
|
528 | 528 | |
529 | 529 | $this->{$key} = $input; |
530 | 530 | $keyMethod = $this->{$method}(); |
531 | 531 | $this->inputs[$key][] = $keyMethod; |
532 | 532 | } |
533 | 533 | } |
534 | - else{ |
|
535 | - if(isset($this->inputs[$key])){ |
|
534 | + else { |
|
535 | + if (isset($this->inputs[$key])) { |
|
536 | 536 | $keyMethod = $this->{$method}(); |
537 | 537 | $this->inputs[$key] = $keyMethod; |
538 | 538 | } |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | { |
551 | 551 | // the auto object validate property is the property |
552 | 552 | // where all of your request values are automatically validated. |
553 | - if(property_exists($this,'autoObjectValidate') |
|
554 | - && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){ |
|
553 | + if (property_exists($this, 'autoObjectValidate') |
|
554 | + && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) { |
|
555 | 555 | $this->autoValidate('autoObjectValidate'); |
556 | 556 | } |
557 | 557 | } |
@@ -40,19 +40,19 @@ |
||
40 | 40 | { |
41 | 41 | $inputs = $this->app->get($this->method); |
42 | 42 | |
43 | - $content = json_decode($this->app['request']->getContent(),1); |
|
43 | + $content = json_decode($this->app['request']->getContent(), 1); |
|
44 | 44 | |
45 | - if(is_array($inputs) && count($inputs)){ |
|
45 | + if (is_array($inputs) && count($inputs)) { |
|
46 | 46 | |
47 | - if(isset($inputs[$this->client->getClientName()])){ |
|
47 | + if (isset($inputs[$this->client->getClientName()])) { |
|
48 | 48 | return $inputs[$this->client->getClientName()]; |
49 | 49 | } |
50 | 50 | return $inputs; |
51 | 51 | } |
52 | 52 | |
53 | - if(is_array($content)){ |
|
53 | + if (is_array($content)) { |
|
54 | 54 | |
55 | - if(isset($content[$this->client->getClientName()])){ |
|
55 | + if (isset($content[$this->client->getClientName()])) { |
|
56 | 56 | return $content[$this->client->getClientName()]; |
57 | 57 | } |
58 | 58 | return $content; |