Passed
Push — master ( 21d927...ee3ef8 )
by Php Easy Api
03:01
created
src/resta/Request/Request.php 2 patches
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         // if we leave the request process to the application side,
59 59
         // then in this case we refer to the requestClient object in
60 60
         // the services section of the store directory.
61
-        (property_exists($this,'app') && $this->app) ? parent::handle() : $this->handle();
61
+        (property_exists($this, 'app') && $this->app) ? parent::handle() : $this->handle();
62 62
     }
63 63
 
64 64
     /**
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
      */
69 69
     private function autoValidate($validate)
70 70
     {
71
-        foreach ($this->{$validate} as $object=>$datas){
72
-            if(Utils::isNamespaceExists($object)){
71
+        foreach ($this->{$validate} as $object=>$datas) {
72
+            if (Utils::isNamespaceExists($object)) {
73 73
                 $getObjectInstance = app()->resolve($object);
74
-                foreach ($datas as $dataKey=>$data){
75
-                    if(is_numeric($dataKey) && method_exists($getObjectInstance,$data)){
76
-                        if(isset($this->origin[$data])){
77
-                            if(!is_array($this->origin[$data])){
74
+                foreach ($datas as $dataKey=>$data) {
75
+                    if (is_numeric($dataKey) && method_exists($getObjectInstance, $data)) {
76
+                        if (isset($this->origin[$data])) {
77
+                            if (!is_array($this->origin[$data])) {
78 78
                                 $this->origin[$data] = array($this->origin[$data]);
79 79
                             }
80
-                            foreach ($this->origin[$data] as $originData){
80
+                            foreach ($this->origin[$data] as $originData) {
81 81
                                 $getObjectInstance->{$data}($originData);
82 82
                             }
83 83
                         }
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 
100 100
         // Determines which HTTP method
101 101
         // the request object will be exposed to.
102
-        if($this->checkProperties('http')){
102
+        if ($this->checkProperties('http')) {
103 103
 
104 104
             // if the current http method does not exist
105 105
             // in the http object, the exception will be thrown.
106
-            if(!in_array($method,$this->http)){
106
+            if (!in_array($method, $this->http)) {
107 107
 
108 108
                 //exception batMethodCall
109 109
                 exception()->badMethodCall(
110
-                    'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",",$this->http).'] ');
110
+                    'Invalid http method process for '.class_basename($this).'.That is accepted http methods ['.implode(",", $this->http).'] ');
111 111
             }
112 112
         }
113 113
     }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         // from the properties of the object properties to
124 124
         // the existing variables, control the array and at least one element.
125
-        return (property_exists($this,$properties)
125
+        return (property_exists($this, $properties)
126 126
             && is_array($this->{$properties}) && count($this->{$properties})) ? true : false;
127 127
     }
128 128
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     {
136 136
         // we are saving the expected values ​​for the request in container.
137 137
         // this record can be returned in exception information.
138
-        app()->register('requestExpected',$this->expected);
138
+        app()->register('requestExpected', $this->expected);
139 139
     }
140 140
 
141 141
     /**
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
     public function except($except)
148 148
     {
149 149
         // the except parameter is a callable value.
150
-        if(is_callable($except)){
151
-            $call = call_user_func_array($except,[$this]);
150
+        if (is_callable($except)) {
151
+            $call = call_user_func_array($except, [$this]);
152 152
             $except = $call;
153 153
         }
154 154
 
155 155
         // except with the except exceptions property
156 156
         // and then assigning them to the inputs property.
157
-        $this->except = array_merge($this->except,$except);
158
-        $this->inputs = array_diff_key($this->inputs,array_flip($this->except));
157
+        $this->except = array_merge($this->except, $except);
158
+        $this->inputs = array_diff_key($this->inputs, array_flip($this->except));
159 159
 
160 160
         return $this;
161 161
     }
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
     {
170 170
         // expected method is executed.
171 171
         // this method is a must for http method values to be found in this property.
172
-        if($this->checkProperties('expected')){
172
+        if ($this->checkProperties('expected')) {
173 173
 
174 174
             // if the expected values are not found in the inputs array,
175 175
             // the exception will be thrown.
176
-            foreach ($this->expected as $expected){
177
-                if(!isset($this->inputs[$expected])){
176
+            foreach ($this->expected as $expected) {
177
+                if (!isset($this->inputs[$expected])) {
178 178
                     exception()->unexpectedValue('You absolutely have to send the value '.$expected.' for request object');
179 179
                 }
180 180
             }
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
     {
191 191
         // check the presence of the generator object
192 192
         // and operate the generator over this object.
193
-        if($this->checkProperties('auto_generators')){
193
+        if ($this->checkProperties('auto_generators')) {
194 194
             $generators = $this->auto_generators;
195 195
         }
196 196
 
197 197
         // check the presence of the generator object
198 198
         // and operate the generator over this object.
199
-        if($this->checkProperties('generators')){
200
-            $generators = array_merge(isset($generators) ? $generators: [],$this->generators);
199
+        if ($this->checkProperties('generators')) {
200
+            $generators = array_merge(isset($generators) ? $generators : [], $this->generators);
201 201
         }
202 202
 
203
-        if(isset($generators)){
203
+        if (isset($generators)) {
204 204
             $this->generatorMethod($generators);
205 205
         }
206 206
     }
@@ -213,30 +213,30 @@  discard block
 block discarded – undo
213 213
     private function generatorMethod($generators)
214 214
     {
215 215
         //generator array object
216
-        foreach ($generators as $generator){
216
+        foreach ($generators as $generator) {
217 217
 
218 218
             //generator method name
219 219
             $generatorMethodName = $generator.'Generator';
220 220
 
221 221
             // if the generator method is present,
222 222
             // the fake value is assigned.
223
-            if(method_exists($this,$generatorMethodName)){
223
+            if (method_exists($this, $generatorMethodName)) {
224 224
 
225 225
                 //fake registration
226
-                if(!isset($this->inputs[$generator])){
226
+                if (!isset($this->inputs[$generator])) {
227 227
                     $this->{$generator} = $this->{$generatorMethodName}();
228 228
                     $this->inputs[$generator] = $this->{$generatorMethodName}();
229 229
                 }
230 230
                 else {
231 231
 
232
-                    if($this->checkProperties('auto_generators_dont_overwrite')
233
-                        && in_array($generator,$this->auto_generators_dont_overwrite)){
232
+                    if ($this->checkProperties('auto_generators_dont_overwrite')
233
+                        && in_array($generator, $this->auto_generators_dont_overwrite)) {
234 234
                         $this->{$generator} = $this->{$generatorMethodName}();
235 235
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
236 236
                     }
237 237
 
238
-                    if($this->checkProperties('generators_dont_overwrite')
239
-                        && in_array($generator,$this->generators_dont_overwrite)){
238
+                    if ($this->checkProperties('generators_dont_overwrite')
239
+                        && in_array($generator, $this->generators_dont_overwrite)) {
240 240
                         $this->{$generator} = $this->{$generatorMethodName}();
241 241
                         $this->inputs[$generator] = $this->{$generatorMethodName}();
242 242
                     }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      */
266 266
     private function getClientObjects()
267 267
     {
268
-        return array_diff_key($this->getObjects(),['inputs'=>[]]);
268
+        return array_diff_key($this->getObjects(), ['inputs'=>[]]);
269 269
     }
270 270
 
271 271
     /**
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
     {
312 312
         // we use the http method to write
313 313
         // the values to the inputs and origin properties.
314
-        foreach($this->requestHttp->resolve() as $key=>$value){
314
+        foreach ($this->requestHttp->resolve() as $key=>$value) {
315 315
 
316 316
             //inputs and origin properties
317 317
             $this->inputs[$key] = $value;
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 
356 356
         // we update the input values ​​after
357 357
         // we receive and check the saved objects.
358
-        foreach ($clientObjects as $key=>$value){
358
+        foreach ($clientObjects as $key=>$value) {
359 359
 
360
-            if(isset($clientObjects['origin'][$key])){
360
+            if (isset($clientObjects['origin'][$key])) {
361 361
 
362 362
                 $this->{$key} = $clientObjects['origin'][$key];
363 363
                 $this->inputs[$key] = $this->{$key};
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 
383 383
         // the request update to be performed using
384 384
         // the method name to be used with the http method.
385
-        $this->setRequestInputs($requestMethod,$key);
385
+        $this->setRequestInputs($requestMethod, $key);
386 386
 
387 387
         // the request update to be performed using
388 388
         // the method name to be used without the http method.
389
-        $this->setRequestInputs($key,$key);
389
+        $this->setRequestInputs($key, $key);
390 390
     }
391 391
 
392 392
     /**
@@ -395,28 +395,28 @@  discard block
 block discarded – undo
395 395
      * @param $method
396 396
      * @param $key
397 397
      */
398
-    private function setRequestInputs($method,$key)
398
+    private function setRequestInputs($method, $key)
399 399
     {
400
-        if(method_exists($this,$method) && $this->reflection->reflectionMethodParams($method)->isProtected){
400
+        if (method_exists($this, $method) && $this->reflection->reflectionMethodParams($method)->isProtected) {
401 401
 
402 402
             //check annotations for method
403
-            $annotation = app()->resolve(RequestAnnotationManager::class,['request'=>$this]);
404
-            $annotation->annotation($method,$key);
403
+            $annotation = app()->resolve(RequestAnnotationManager::class, ['request'=>$this]);
404
+            $annotation->annotation($method, $key);
405 405
 
406
-            if(isset($this->inputs[$key]) && is_array($this->inputs[$key])){
406
+            if (isset($this->inputs[$key]) && is_array($this->inputs[$key])) {
407 407
 
408 408
                 $inputKeys = $this->inputs[$key];
409 409
 
410 410
                 $this->inputs[$key] = [];
411
-                foreach ($inputKeys as $input){
411
+                foreach ($inputKeys as $input) {
412 412
 
413 413
                     $this->{$key}           = $input;
414 414
                     $keyMethod              = $this->{$method}();
415 415
                     $this->inputs[$key][]   = $keyMethod;
416 416
                 }
417 417
             }
418
-            else{
419
-                if(isset($this->inputs[$key])){
418
+            else {
419
+                if (isset($this->inputs[$key])) {
420 420
                     $keyMethod = $this->{$method}();
421 421
                     $this->inputs[$key] = $keyMethod;
422 422
                 }
@@ -432,22 +432,22 @@  discard block
 block discarded – undo
432 432
      */
433 433
     private function validation()
434 434
     {
435
-        if(property_exists($this,'autoObjectValidate') && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)){
435
+        if (property_exists($this, 'autoObjectValidate') && is_array($this->autoObjectValidate) && count($this->autoObjectValidate)) {
436 436
             $this->autoValidate('autoObjectValidate');
437 437
         }
438 438
         // we need to find the rule method
439 439
         // because we can not validate it.
440
-        if(method_exists($this,'rule')){
440
+        if (method_exists($this, 'rule')) {
441 441
             $this->rule();
442 442
         }
443 443
 
444 444
         // if we only want to make a rule of
445 445
         // the specified request object, we will use
446 446
         // the rule method with the prefix of the request object.
447
-        $validName=strtolower(str_replace('Request','',class_basename($this))).'Rule';
447
+        $validName = strtolower(str_replace('Request', '', class_basename($this))).'Rule';
448 448
 
449 449
         //if the specified method exists;
450
-        if(method_exists($this,$validName)){
450
+        if (method_exists($this, $validName)) {
451 451
             $this->{$validName}();
452 452
         }
453 453
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -226,8 +226,7 @@  discard block
 block discarded – undo
226 226
                 if(!isset($this->inputs[$generator])){
227 227
                     $this->{$generator} = $this->{$generatorMethodName}();
228 228
                     $this->inputs[$generator] = $this->{$generatorMethodName}();
229
-                }
230
-                else {
229
+                } else {
231 230
 
232 231
                     if($this->checkProperties('auto_generators_dont_overwrite')
233 232
                         && in_array($generator,$this->auto_generators_dont_overwrite)){
@@ -414,8 +413,7 @@  discard block
 block discarded – undo
414 413
                     $keyMethod              = $this->{$method}();
415 414
                     $this->inputs[$key][]   = $keyMethod;
416 415
                 }
417
-            }
418
-            else{
416
+            } else{
419 417
                 if(isset($this->inputs[$key])){
420 418
                     $keyMethod = $this->{$method}();
421 419
                     $this->inputs[$key] = $keyMethod;
Please login to merge, or discard this patch.
src/resta/Request/RequestAnnotationAbstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @param $key
23 23
      * @return mixed
24 24
      */
25
-    abstract function annotation($method,$key);
25
+    abstract function annotation($method, $key);
26 26
 
27 27
     /**
28 28
      * get input values from request object
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @param $reflection
54 54
      */
55
-    public function setReflection($reflection){
55
+    public function setReflection($reflection) {
56 56
 
57 57
         $this->request = ClosureDispatcher::bind($reflection);
58 58
     }
Please login to merge, or discard this patch.
src/resta/Request/RequestAnnotationManager.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @param ApplicationContracts $app
24 24
      * @param $request
25 25
      */
26
-    public function __construct(ApplicationContracts $app,$request)
26
+    public function __construct(ApplicationContracts $app, $request)
27 27
     {
28 28
         parent::__construct($app);
29 29
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @throws \ReflectionException
42 42
      */
43
-    public function annotation($method,$key)
43
+    public function annotation($method, $key)
44 44
     {
45 45
         //set annotation value with getting reflection
46 46
         $reflection = $this->getReflection('reflection')->reflectionMethodParams($method);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $this->getException();
54 54
 
55 55
         //get regex from request object
56
-        $this->getRegex($method,$key);
56
+        $this->getRegex($method, $key);
57 57
     }
58 58
 
59 59
     /**
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
      * @param $key
63 63
      * @param $data
64 64
      */
65
-    private function catchException($key,$data)
65
+    private function catchException($key, $data)
66 66
     {
67
-        if(isset($this->exceptionParams[$key])){
67
+        if (isset($this->exceptionParams[$key])) {
68 68
             $keyParams = ($this->exceptionParams[$key]['params']) ?? [];
69
-            exception($this->exceptionParams[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$data.')');
69
+            exception($this->exceptionParams[$key]['name'], $keyParams)->unexpectedValue($key.' input value is not valid as format ('.$data.')');
70 70
         }
71
-        else{
71
+        else {
72 72
             exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
73 73
         }
74 74
     }
@@ -80,20 +80,20 @@  discard block
 block discarded – undo
80 80
      */
81 81
     private function getException()
82 82
     {
83
-        if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
83
+        if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
84 84
 
85
-            $exceptionSpaceExplode = explode(" ",$exception[1]);
86
-            foreach ($exceptionSpaceExplode as $exceptions){
87
-                $exceptionsDotExplode = explode(":",$exceptions);
85
+            $exceptionSpaceExplode = explode(" ", $exception[1]);
86
+            foreach ($exceptionSpaceExplode as $exceptions) {
87
+                $exceptionsDotExplode = explode(":", $exceptions);
88 88
                 $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1];
89 89
             }
90 90
 
91
-            if(isset($this->exceptionParams[$key]['params'])){
92
-                $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
91
+            if (isset($this->exceptionParams[$key]['params'])) {
92
+                $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
93 93
                 unset($this->exceptionParams[$key]['params']);
94
-                foreach ($paramsCommaExplode as $params){
95
-                    $paramsEqualExplode = explode("=",$params);
96
-                    if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
94
+                foreach ($paramsCommaExplode as $params) {
95
+                    $paramsEqualExplode = explode("=", $params);
96
+                    if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
97 97
                         $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1];
98 98
                     }
99 99
                 }
@@ -107,23 +107,23 @@  discard block
 block discarded – undo
107 107
      * @param $method
108 108
      * @param $key
109 109
      */
110
-    private function getRegex($method,$key)
110
+    private function getRegex($method, $key)
111 111
     {
112
-        if(preg_match('@regex\((.*?)\)\r\n@is',$this->annotation,$regex)){
113
-            if(isset($this->inputs[$key])){
112
+        if (preg_match('@regex\((.*?)\)\r\n@is', $this->annotation, $regex)) {
113
+            if (isset($this->inputs[$key])) {
114 114
 
115
-                if(is_array($this->inputs[$key])){
115
+                if (is_array($this->inputs[$key])) {
116 116
 
117
-                    foreach ($this->inputs[$key] as $this->inputsKey=>$this->inputsValue){
118
-                        if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
119
-                            $this->catchException($key,$regex[1]);
117
+                    foreach ($this->inputs[$key] as $this->inputsKey=>$this->inputsValue) {
118
+                        if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) {
119
+                            $this->catchException($key, $regex[1]);
120 120
                         }
121 121
                     }
122 122
                 }
123
-                else{
123
+                else {
124 124
 
125
-                    if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
126
-                        $this->catchException($key,$regex[1]);
125
+                    if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
126
+                        $this->catchException($key, $regex[1]);
127 127
                     }
128 128
                 }
129 129
             }
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
      */
138 138
     private function getRemove()
139 139
     {
140
-        if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){
141
-            if(isset($this->inputs[$key])){
142
-                if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
140
+        if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) {
141
+            if (isset($this->inputs[$key])) {
142
+                if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
143 143
                     unset($this->inputs[$key]);
144 144
                 }
145 145
             }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -67,8 +67,7 @@  discard block
 block discarded – undo
67 67
         if(isset($this->exceptionParams[$key])){
68 68
             $keyParams = ($this->exceptionParams[$key]['params']) ?? [];
69 69
             exception($this->exceptionParams[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$data.')');
70
-        }
71
-        else{
70
+        } else{
72 71
             exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
73 72
         }
74 73
     }
@@ -119,8 +118,7 @@  discard block
 block discarded – undo
119 118
                             $this->catchException($key,$regex[1]);
120 119
                         }
121 120
                     }
122
-                }
123
-                else{
121
+                } else{
124 122
 
125 123
                     if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
126 124
                         $this->catchException($key,$regex[1]);
Please login to merge, or discard this patch.