Test Setup Failed
Push — master ( 526252...aeaf6f )
by Php Easy Api
05:09
created
src/resta/Client/ClientAnnotationManager.php 2 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * @param ApplicationContracts $app
22 22
      * @param $request
23 23
      */
24
-    public function __construct(ApplicationContracts $app,$request)
24
+    public function __construct(ApplicationContracts $app, $request)
25 25
     {
26 26
         parent::__construct($app);
27 27
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * @param $key
38 38
      * @return mixed|void
39 39
      */
40
-    public function annotation($method,$key)
40
+    public function annotation($method, $key)
41 41
     {
42 42
         //set annotation value with getting reflection
43 43
         $reflection = $this->getReflection('reflection')->reflectionMethodParams($method);
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
      * @param string $key
63 63
      * @param null|string $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
 
69 69
             //get key params for exception params
70 70
             $keyParams = ($this->exceptionParams[$key]['params']) ?? [];
71 71
 
72 72
             //catch exception
73
-            exception($this->exceptionParams[$key]['name'],$keyParams)
73
+            exception($this->exceptionParams[$key]['name'], $keyParams)
74 74
                 ->unexpectedValue($this->exceptionParams[$key]['name'].' input value is not valid as format ('.$data.')');
75 75
         }
76
-        else{
76
+        else {
77 77
             //catch exception
78 78
             exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
79 79
         }
@@ -86,23 +86,23 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private function getException($key)
88 88
     {
89
-        if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
89
+        if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
90 90
 
91
-            $exceptionSpaceExplode = explode(" ",$exception[1]);
91
+            $exceptionSpaceExplode = explode(" ", $exception[1]);
92 92
 
93
-            foreach ($exceptionSpaceExplode as $exceptions){
94
-                $exceptionsDotExplode = explode(":",$exceptions);
93
+            foreach ($exceptionSpaceExplode as $exceptions) {
94
+                $exceptionsDotExplode = explode(":", $exceptions);
95 95
                 $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1];
96 96
             }
97 97
 
98
-            if(isset($this->exceptionParams[$key]['params'])){
98
+            if (isset($this->exceptionParams[$key]['params'])) {
99 99
 
100
-                $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
100
+                $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
101 101
                 unset($this->exceptionParams[$key]['params']);
102 102
 
103
-                foreach ($paramsCommaExplode as $params){
104
-                    $paramsEqualExplode = explode("=",$params);
105
-                    if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
103
+                foreach ($paramsCommaExplode as $params) {
104
+                    $paramsEqualExplode = explode("=", $params);
105
+                    if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
106 106
                         $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1];
107 107
                     }
108 108
                 }
@@ -119,37 +119,37 @@  discard block
 block discarded – undo
119 119
     {
120 120
         // with the method based regex annotation,
121 121
         // we check the rule definition for our requests.
122
-        if(preg_match('@regex\((.*?)\)\r\n@is',$this->annotation,$regex)){
123
-            if(isset($this->inputs[$key])){
122
+        if (preg_match('@regex\((.*?)\)\r\n@is', $this->annotation, $regex)) {
123
+            if (isset($this->inputs[$key])) {
124 124
 
125 125
                 // for the definition of rules,
126 126
                 // our inputs can be array and in this case we offer array option for user comfort.
127
-                if(is_array($this->inputs[$key])){
127
+                if (is_array($this->inputs[$key])) {
128 128
 
129
-                    foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue){
129
+                    foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue) {
130 130
 
131
-                        if(is_array($this->inputsValue)){
131
+                        if (is_array($this->inputsValue)) {
132 132
 
133
-                            foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem){
134
-                                if(!preg_match('@'.$regex[1].'@is',$inputsValueItem)){
135
-                                    $this->catchException($key,$regex[1]);
133
+                            foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem) {
134
+                                if (!preg_match('@'.$regex[1].'@is', $inputsValueItem)) {
135
+                                    $this->catchException($key, $regex[1]);
136 136
                                 }
137 137
                             }
138 138
 
139 139
                         }
140
-                        else{
141
-                            if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
142
-                                $this->catchException($key,$regex[1]);
140
+                        else {
141
+                            if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) {
142
+                                $this->catchException($key, $regex[1]);
143 143
                             }
144 144
                         }
145 145
 
146 146
                     }
147 147
                 }
148
-                else{
148
+                else {
149 149
 
150 150
                     // we control the regex rule that evaluates when only string arrives.
151
-                    if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
152
-                        $this->catchException($key,$regex[1]);
151
+                    if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
152
+                        $this->catchException($key, $regex[1]);
153 153
                     }
154 154
                 }
155 155
             }
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
      */
165 165
     private function getRemove($key)
166 166
     {
167
-        if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){
168
-            if(isset($this->inputs[$key])){
169
-                if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
167
+        if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) {
168
+            if (isset($this->inputs[$key])) {
169
+                if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
170 170
                     unset($this->inputs[$key]);
171 171
                 }
172 172
             }
@@ -180,16 +180,16 @@  discard block
 block discarded – undo
180 180
      */
181 181
     private function getRules($key)
182 182
     {
183
-        if(preg_match('@rule\((.*?)\)\r\n@is',$this->annotation,$rule)){
183
+        if (preg_match('@rule\((.*?)\)\r\n@is', $this->annotation, $rule)) {
184 184
 
185 185
             $requestRules = $this->getReflection('rules');
186 186
 
187
-            $rules = explode(":",$rule[1]);
188
-            if(isset($this->inputs[$key])){
189
-                foreach($rules as $rule){
190
-                    if(isset($requestRules[$rule])){
191
-                        if(!preg_match('@'.$requestRules[$rule].'@',$this->inputs[$key])){
192
-                            exception($rule,['key'=>$key])
187
+            $rules = explode(":", $rule[1]);
188
+            if (isset($this->inputs[$key])) {
189
+                foreach ($rules as $rule) {
190
+                    if (isset($requestRules[$rule])) {
191
+                        if (!preg_match('@'.$requestRules[$rule].'@', $this->inputs[$key])) {
192
+                            exception($rule, ['key'=>$key])
193 193
                                 ->invalidArgument($key.' input value is not valid for '.$rule.' request rule');
194 194
                         }
195 195
                     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,8 +72,7 @@  discard block
 block discarded – undo
72 72
             //catch exception
73 73
             exception($this->exceptionParams[$key]['name'],$keyParams)
74 74
                 ->unexpectedValue($this->exceptionParams[$key]['name'].' input value is not valid as format ('.$data.')');
75
-        }
76
-        else{
75
+        } else{
77 76
             //catch exception
78 77
             exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
79 78
         }
@@ -136,16 +135,14 @@  discard block
 block discarded – undo
136 135
                                 }
137 136
                             }
138 137
 
139
-                        }
140
-                        else{
138
+                        } else{
141 139
                             if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
142 140
                                 $this->catchException($key,$regex[1]);
143 141
                             }
144 142
                         }
145 143
 
146 144
                     }
147
-                }
148
-                else{
145
+                } else{
149 146
 
150 147
                     // we control the regex rule that evaluates when only string arrives.
151 148
                     if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
Please login to merge, or discard this patch.