Test Setup Failed
Push — master ( 380e22...5de2dd )
by Php Easy Api
02:56
created
src/resta/Request/Request.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -57,25 +57,25 @@  discard block
 block discarded – undo
57 57
     private function autoValidate($validate)
58 58
     {
59 59
         //we get the values ​​to auto-validate.
60
-        foreach ($this->{$validate} as $object=>$datas){
60
+        foreach ($this->{$validate} as $object=>$datas) {
61 61
 
62 62
             // the auto-validate value must necessarily represent a class.
63 63
             // otherwise auto-validate is not used.
64
-            if(Utils::isNamespaceExists($object)){
64
+            if (Utils::isNamespaceExists($object)) {
65 65
                 $getObjectInstance = app()->resolve($object);
66 66
 
67 67
                 // we get the index values,
68 68
                 // which are called methods of the auto-validate value that represents the class.
69
-                foreach ($datas as $dataKey=>$data){
69
+                foreach ($datas as $dataKey=>$data) {
70 70
 
71 71
                     // if the methods of the auto-validate class resolved by the container resolve method apply,
72 72
                     // the process of auto-validate automatic implementation will be completed.
73
-                    if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){
74
-                        if(isset($this->origin[$data])){
75
-                            if(!is_array($this->origin[$data])){
73
+                    if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) {
74
+                        if (isset($this->origin[$data])) {
75
+                            if (!is_array($this->origin[$data])) {
76 76
                                 $this->origin[$data] = array($this->origin[$data]);
77 77
                             }
78
-                            foreach ($this->origin[$data] as $originData){
78
+                            foreach ($this->origin[$data] as $originData) {
79 79
                                 $getObjectInstance->{$data}($originData);
80 80
                             }
81 81
                         }
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
 
98 98
         // Determines which HTTP method
99 99
         // the request object will be exposed to.
100
-        if($this->checkProperties('http')){
100
+        if ($this->checkProperties('http')) {
101 101
 
102 102
             // if the current http method does not exist
103 103
             // in the http object, the exception will be thrown.
104
-            if(!in_array($method,$this->http)){
104
+            if (!in_array($method, $this->http)) {
105 105
 
106 106
                 //exception batMethodCall
107 107
                 exception()->badMethodCall(
108
-                    'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
108
+                    'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
109 109
             }
110 110
         }
111 111
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         // from the properties of the object properties to
122 122
         // the existing variables, control the array and at least one element.
123
-        return (property_exists($this,$properties)
123
+        return (property_exists($this, $properties)
124 124
             && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
125 125
     }
126 126
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         // we are saving the expected values ​​for the request in container.
135 135
         // this record can be returned in exception information.
136
-        app()->register('requestExpected',$this->expected);
136
+        app()->register('requestExpected', $this->expected);
137 137
     }
138 138
 
139 139
     /**
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
     public function except($except)
146 146
     {
147 147
         // the except parameter is a callable value.
148
-        if(is_callable($except)){
149
-            $call = call_user_func_array($except,[$this]);
148
+        if (is_callable($except)) {
149
+            $call = call_user_func_array($except, [$this]);
150 150
             $except = $call;
151 151
         }
152 152
 
153 153
         // except with the except exceptions property
154 154
         // and then assigning them to the inputs property.
155
-        $this->except = array_merge($this->except,$except);
156
-        $this->inputs = array_diff_key($this->inputs,array_flip($this->except));
155
+        $this->except = array_merge($this->except, $except);
156
+        $this->inputs = array_diff_key($this->inputs, array_flip($this->except));
157 157
 
158 158
         return $this;
159 159
     }
@@ -167,27 +167,27 @@  discard block
 block discarded – undo
167 167
     {
168 168
         // expected method is executed.
169 169
         // this method is a must for http method values to be found in this property.
170
-        if($this->checkProperties('expected')){
170
+        if ($this->checkProperties('expected')) {
171 171
 
172 172
             // if the expected values are not found in the inputs array,
173 173
             // the exception will be thrown.
174
-            foreach ($this->expected as $expected){
174
+            foreach ($this->expected as $expected) {
175 175
 
176 176
                 $expectedValues = [];
177 177
 
178 178
                 // mandatory expected data for each key can be separated by | operator.
179 179
                 // this is evaluated as "or".
180
-                foreach($expectedData = explode("|",$expected) as $inputs){
181
-                    if(!isset($this->inputs[$inputs])){
180
+                foreach ($expectedData = explode("|", $expected) as $inputs) {
181
+                    if (!isset($this->inputs[$inputs])) {
182 182
                         $expectedValues[] = $inputs;
183 183
                     }
184 184
                 }
185 185
 
186 186
                 // if the expectedData and expectedValues ​​
187 187
                 // array are numerically equal to the expected key, the exception is thrown.
188
-                if(count($expectedData)===count($expectedValues)){
188
+                if (count($expectedData)===count($expectedValues)) {
189 189
                     exception()
190
-                        ->unexpectedValue('You absolutely have to send the value '.implode(" or ",$expectedValues).' for request object');
190
+                        ->unexpectedValue('You absolutely have to send the value '.implode(" or ", $expectedValues).' for request object');
191 191
                 }
192 192
             }
193 193
         }
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
     {
203 203
         // check the presence of the generator object
204 204
         // and operate the generator over this object.
205
-        if($this->checkProperties('auto_generators')){
205
+        if ($this->checkProperties('auto_generators')) {
206 206
             $generators = $this->getAutoGenerators();
207 207
         }
208 208
 
209 209
         // check the presence of the generator object
210 210
         // and operate the generator over this object.
211
-        if($this->checkProperties('generators')){
212
-            $generators = array_merge(isset($generators) ? $generators: [],$this->getGenerators());
211
+        if ($this->checkProperties('generators')) {
212
+            $generators = array_merge(isset($generators) ? $generators : [], $this->getGenerators());
213 213
         }
214 214
 
215
-        if(isset($generators)){
215
+        if (isset($generators)) {
216 216
             $this->generatorMethod($generators);
217 217
         }
218 218
     }
@@ -227,30 +227,30 @@  discard block
 block discarded – undo
227 227
     private function generatorMethod($generators)
228 228
     {
229 229
         //generator array object
230
-        foreach ($generators as $generator){
230
+        foreach ($generators as $generator) {
231 231
 
232 232
             //generator method name
233 233
             $generatorMethodName = $generator.'Generator';
234 234
 
235 235
             // if the generator method is present,
236 236
             // the fake value is assigned.
237
-            if(method_exists($this,$generatorMethodName)){
237
+            if (method_exists($this, $generatorMethodName)) {
238 238
 
239 239
                 //fake registration
240
-                if(!isset($this->inputs[$generator])){
240
+                if (!isset($this->inputs[$generator])) {
241 241
                     $this->{$generator} = $this->{$generatorMethodName}();
242 242
                     $this->inputs[$generator] = $this->{$generatorMethodName}();
243 243
                 }
244 244
                 else {
245 245
 
246
-                    if($this->checkProperties('auto_generators_dont_overwrite')
247
-                        && in_array($generator,$this->getAutoGeneratorsDontOverwrite())){
246
+                    if ($this->checkProperties('auto_generators_dont_overwrite')
247
+                        && in_array($generator, $this->getAutoGeneratorsDontOverwrite())) {
248 248
                         $this->{$generator} = $this->{$generatorMethodName}();
249 249
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
250 250
                     }
251 251
 
252
-                    if($this->checkProperties('generators_dont_overwrite')
253
-                        && in_array($generator,$this->getGeneratorsDontOverwrite())){
252
+                    if ($this->checkProperties('generators_dont_overwrite')
253
+                        && in_array($generator, $this->getGeneratorsDontOverwrite())) {
254 254
                         $this->{$generator} = $this->{$generatorMethodName}();
255 255
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
256 256
                     }
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     {
298 298
         // we use the http method to write
299 299
         // the values to the inputs and origin properties.
300
-        foreach($this->requestHttp->resolve() as $key=>$value){
300
+        foreach ($this->requestHttp->resolve() as $key=>$value) {
301 301
 
302 302
             //inputs and origin properties
303 303
             $this->inputs[$key] = $value;
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 
342 342
         // we update the input values ​​after
343 343
         // we receive and check the saved objects.
344
-        foreach ($clientObjects as $key=>$value){
344
+        foreach ($clientObjects as $key=>$value) {
345 345
 
346
-            if(isset($clientObjects['origin'][$key])){
346
+            if (isset($clientObjects['origin'][$key])) {
347 347
 
348 348
                 $this->{$key} = $clientObjects['origin'][$key];
349 349
                 $this->inputs[$key] = $this->{$key};
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
 
371 371
         // the request update to be performed using
372 372
         // the method name to be used with the http method.
373
-        $this->setRequestInputs($requestMethod,$key);
373
+        $this->setRequestInputs($requestMethod, $key);
374 374
 
375 375
         // the request update to be performed using
376 376
         // the method name to be used without the http method.
377
-        $this->setRequestInputs($key,$key);
377
+        $this->setRequestInputs($key, $key);
378 378
     }
379 379
 
380 380
     /**
@@ -385,28 +385,28 @@  discard block
 block discarded – undo
385 385
      *
386 386
      * @throws ReflectionExceptionAlias
387 387
      */
388
-    private function setRequestInputs($method,$key)
388
+    private function setRequestInputs($method, $key)
389 389
     {
390
-        if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
390
+        if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
391 391
 
392 392
             //check annotations for method
393
-            $annotation = app()->resolve(RequestAnnotationManager::class,['request'=>$this]);
394
-            $annotation->annotation($method,$key);
393
+            $annotation = app()->resolve(RequestAnnotationManager::class, ['request'=>$this]);
394
+            $annotation->annotation($method, $key);
395 395
 
396
-            if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
396
+            if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
397 397
 
398 398
                 $inputKeys = $this->inputs[$key];
399 399
 
400 400
                 $this->inputs[$key] = [];
401
-                foreach ($inputKeys as $input){
401
+                foreach ($inputKeys as $input) {
402 402
 
403 403
                     $this->{$key}           = $input;
404 404
                     $keyMethod              = $this->{$method}();
405 405
                     $this->inputs[$key][]   = $keyMethod;
406 406
                 }
407 407
             }
408
-            else{
409
-                if(isset($this->inputs[$key])){
408
+            else {
409
+                if (isset($this->inputs[$key])) {
410 410
                     $keyMethod = $this->{$method}();
411 411
                     $this->inputs[$key] = $keyMethod;
412 412
                 }
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
     {
425 425
         // the auto object validate property is the property
426 426
         // where all of your request values ​​are automatically validated.
427
-        if(property_exists($this,'autoObjectValidate')
428
-            && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
427
+        if (property_exists($this, 'autoObjectValidate')
428
+            && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
429 429
             $this->autoValidate('autoObjectValidate');
430 430
         }
431 431
     }
Please login to merge, or discard this patch.