Passed
Push — master ( a1a81a...636c38 )
by Php Easy Api
03:08
created
src/resta/Request/Request.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
     private function autoValidate($validate)
55 55
     {
56 56
         //we get the values ​​to auto-validate.
57
-        foreach ($this->{$validate} as $object=>$datas){
57
+        foreach ($this->{$validate} as $object=>$datas) {
58 58
 
59 59
             // the auto-validate value must necessarily represent a class.
60 60
             // otherwise auto-validate is not used.
61
-            if(Utils::isNamespaceExists($object)){
61
+            if (Utils::isNamespaceExists($object)) {
62 62
                 $getObjectInstance = app()->resolve($object);
63 63
 
64 64
                 // we get the index values,
65 65
                 // which are called methods of the auto-validate value that represents the class.
66
-                foreach ($datas as $dataKey=>$data){
66
+                foreach ($datas as $dataKey=>$data) {
67 67
 
68 68
                     // if the methods of the auto-validate class resolved by the container resolve method apply,
69 69
                     // the process of auto-validate automatic implementation will be completed.
70
-                    if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){
71
-                        if(isset($this->origin[$data])){
72
-                            if(!is_array($this->origin[$data])){
70
+                    if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) {
71
+                        if (isset($this->origin[$data])) {
72
+                            if (!is_array($this->origin[$data])) {
73 73
                                 $this->origin[$data] = array($this->origin[$data]);
74 74
                             }
75
-                            foreach ($this->origin[$data] as $originData){
75
+                            foreach ($this->origin[$data] as $originData) {
76 76
                                 $getObjectInstance->{$data}($originData);
77 77
                             }
78 78
                         }
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
 
95 95
         // Determines which HTTP method
96 96
         // the request object will be exposed to.
97
-        if($this->checkProperties('http')){
97
+        if ($this->checkProperties('http')) {
98 98
 
99 99
             // if the current http method does not exist
100 100
             // in the http object, the exception will be thrown.
101
-            if(!in_array($method,$this->http)){
101
+            if (!in_array($method, $this->http)) {
102 102
 
103 103
                 //exception batMethodCall
104 104
                 exception()->badMethodCall(
105 105
                     'Invalid http method process for 
106
-                    '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
106
+                    '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
107 107
             }
108 108
         }
109 109
     }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     {
119 119
         // from the properties of the object properties to
120 120
         // the existing variables, control the array and at least one element.
121
-        return (property_exists($this,$properties)
121
+        return (property_exists($this, $properties)
122 122
             && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
123 123
     }
124 124
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     {
132 132
         // we are saving the expected values ​​for the request in container.
133 133
         // this record can be returned in exception information.
134
-        app()->register('requestExpected',$this->expected);
134
+        app()->register('requestExpected', $this->expected);
135 135
     }
136 136
 
137 137
     /**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
     public function except($except)
144 144
     {
145 145
         // the except parameter is a callable value.
146
-        if(is_callable($except)){
147
-            $call = call_user_func_array($except,[$this]);
146
+        if (is_callable($except)) {
147
+            $call = call_user_func_array($except, [$this]);
148 148
             $except = $call;
149 149
         }
150 150
 
151 151
         // except with the except exceptions property
152 152
         // and then assigning them to the inputs property.
153
-        $this->except = array_merge($this->except,$except);
154
-        $this->inputs = array_diff_key($this->inputs,array_flip($this->except));
153
+        $this->except = array_merge($this->except, $except);
154
+        $this->inputs = array_diff_key($this->inputs, array_flip($this->except));
155 155
 
156 156
         return $this;
157 157
     }
@@ -165,28 +165,28 @@  discard block
 block discarded – undo
165 165
     {
166 166
         // expected method is executed.
167 167
         // this method is a must for http method values to be found in this property.
168
-        if($this->checkProperties('expected')){
168
+        if ($this->checkProperties('expected')) {
169 169
 
170 170
             // if the expected values are not found in the inputs array,
171 171
             // the exception will be thrown.
172
-            foreach ($this->expected as $expected){
172
+            foreach ($this->expected as $expected) {
173 173
 
174 174
                 $expectedValues = [];
175 175
 
176 176
                 // mandatory expected data for each key can be separated by | operator.
177 177
                 // this is evaluated as "or".
178
-                foreach($expectedData = explode("|",$expected) as $inputs){
179
-                    if(!isset($this->inputs[$inputs])){
178
+                foreach ($expectedData = explode("|", $expected) as $inputs) {
179
+                    if (!isset($this->inputs[$inputs])) {
180 180
                         $expectedValues[] = $inputs;
181 181
                     }
182 182
                 }
183 183
 
184 184
                 // if the expectedData and expectedValues ​​
185 185
                 // array are numerically equal to the expected key, the exception is thrown.
186
-                if(count($expectedData)===count($expectedValues)){
186
+                if (count($expectedData)===count($expectedValues)) {
187 187
                     exception()
188 188
                         ->unexpectedValue('You absolutely have to send the value 
189
-                        '.implode(" or ",$expectedValues).' for request object');
189
+                        '.implode(" or ", $expectedValues).' for request object');
190 190
                 }
191 191
             }
192 192
         }
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
     {
202 202
         // check the presence of the generator object
203 203
         // and operate the generator over this object.
204
-        if($this->checkProperties('auto_generators')){
204
+        if ($this->checkProperties('auto_generators')) {
205 205
             $generators = $this->auto_generators;
206 206
         }
207 207
 
208 208
         // check the presence of the generator object
209 209
         // and operate the generator over this object.
210
-        if($this->checkProperties('generators')){
211
-            $generators = array_merge(isset($generators) ? $generators: [],$this->generators);
210
+        if ($this->checkProperties('generators')) {
211
+            $generators = array_merge(isset($generators) ? $generators : [], $this->generators);
212 212
         }
213 213
 
214
-        if(isset($generators)){
214
+        if (isset($generators)) {
215 215
             $this->generatorMethod($generators);
216 216
         }
217 217
     }
@@ -224,30 +224,30 @@  discard block
 block discarded – undo
224 224
     private function generatorMethod($generators)
225 225
     {
226 226
         //generator array object
227
-        foreach ($generators as $generator){
227
+        foreach ($generators as $generator) {
228 228
 
229 229
             //generator method name
230 230
             $generatorMethodName = $generator.'Generator';
231 231
 
232 232
             // if the generator method is present,
233 233
             // the fake value is assigned.
234
-            if(method_exists($this,$generatorMethodName)){
234
+            if (method_exists($this, $generatorMethodName)) {
235 235
 
236 236
                 //fake registration
237
-                if(!isset($this->inputs[$generator])){
237
+                if (!isset($this->inputs[$generator])) {
238 238
                     $this->{$generator} = $this->{$generatorMethodName}();
239 239
                     $this->inputs[$generator] = $this->{$generatorMethodName}();
240 240
                 }
241 241
                 else {
242 242
 
243
-                    if($this->checkProperties('auto_generators_dont_overwrite')
244
-                        && in_array($generator,$this->auto_generators_dont_overwrite)){
243
+                    if ($this->checkProperties('auto_generators_dont_overwrite')
244
+                        && in_array($generator, $this->auto_generators_dont_overwrite)) {
245 245
                         $this->{$generator} = $this->{$generatorMethodName}();
246 246
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
247 247
                     }
248 248
 
249
-                    if($this->checkProperties('generators_dont_overwrite')
250
-                        && in_array($generator,$this->generators_dont_overwrite)){
249
+                    if ($this->checkProperties('generators_dont_overwrite')
250
+                        && in_array($generator, $this->generators_dont_overwrite)) {
251 251
                         $this->{$generator} = $this->{$generatorMethodName}();
252 252
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
253 253
                     }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     {
293 293
         // we use the http method to write
294 294
         // the values to the inputs and origin properties.
295
-        foreach($this->requestHttp->resolve() as $key=>$value){
295
+        foreach ($this->requestHttp->resolve() as $key=>$value) {
296 296
 
297 297
             //inputs and origin properties
298 298
             $this->inputs[$key] = $value;
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 
337 337
         // we update the input values ​​after
338 338
         // we receive and check the saved objects.
339
-        foreach ($clientObjects as $key=>$value){
339
+        foreach ($clientObjects as $key=>$value) {
340 340
 
341
-            if(isset($clientObjects['origin'][$key])){
341
+            if (isset($clientObjects['origin'][$key])) {
342 342
 
343 343
                 $this->{$key} = $clientObjects['origin'][$key];
344 344
                 $this->inputs[$key] = $this->{$key};
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
 
364 364
         // the request update to be performed using
365 365
         // the method name to be used with the http method.
366
-        $this->setRequestInputs($requestMethod,$key);
366
+        $this->setRequestInputs($requestMethod, $key);
367 367
 
368 368
         // the request update to be performed using
369 369
         // the method name to be used without the http method.
370
-        $this->setRequestInputs($key,$key);
370
+        $this->setRequestInputs($key, $key);
371 371
     }
372 372
 
373 373
     /**
@@ -378,28 +378,28 @@  discard block
 block discarded – undo
378 378
      *
379 379
      * @throws \ReflectionException
380 380
      */
381
-    private function setRequestInputs($method,$key)
381
+    private function setRequestInputs($method, $key)
382 382
     {
383
-        if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
383
+        if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
384 384
 
385 385
             //check annotations for method
386
-            $annotation = app()->resolve(RequestAnnotationManager::class,['request'=>$this]);
387
-            $annotation->annotation($method,$key);
386
+            $annotation = app()->resolve(RequestAnnotationManager::class, ['request'=>$this]);
387
+            $annotation->annotation($method, $key);
388 388
 
389
-            if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
389
+            if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
390 390
 
391 391
                 $inputKeys = $this->inputs[$key];
392 392
 
393 393
                 $this->inputs[$key] = [];
394
-                foreach ($inputKeys as $input){
394
+                foreach ($inputKeys as $input) {
395 395
 
396 396
                     $this->{$key}           = $input;
397 397
                     $keyMethod              = $this->{$method}();
398 398
                     $this->inputs[$key][]   = $keyMethod;
399 399
                 }
400 400
             }
401
-            else{
402
-                if(isset($this->inputs[$key])){
401
+            else {
402
+                if (isset($this->inputs[$key])) {
403 403
                     $keyMethod = $this->{$method}();
404 404
                     $this->inputs[$key] = $keyMethod;
405 405
                 }
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
     {
418 418
         // the auto object validate property is the property
419 419
         // where all of your request values ​​are automatically validated.
420
-        if(property_exists($this,'autoObjectValidate')
421
-            && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
420
+        if (property_exists($this, 'autoObjectValidate')
421
+            && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
422 422
             $this->autoValidate('autoObjectValidate');
423 423
         }
424 424
     }
Please login to merge, or discard this patch.
src/resta/Request/RequestAbstract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
      */
32 32
     protected function getClientObjects()
33 33
     {
34
-        return array_diff_key($this->getObjects(),['inputs'=>[]]);
34
+        return array_diff_key($this->getObjects(), ['inputs'=>[]]);
35 35
     }
36 36
 
37 37
     /**
Please login to merge, or discard this patch.