Test Setup Failed
Push — master ( 4c8cfe...26eaf4 )
by Php Easy Api
08:26 queued 04:12
created
src/resta/Router/Route.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
      * @param $urlRoute
44 44
      * @return int|string
45 45
      */
46
-    private static function checkArrayEqual($patterns,$urlRoute)
46
+    private static function checkArrayEqual($patterns, $urlRoute)
47 47
     {
48 48
         // calculates the equality difference between
49 49
         // the route pattern and the urlRoute value.
50
-        foreach ($patterns as $key=>$pattern){
50
+        foreach ($patterns as $key=>$pattern) {
51 51
 
52
-            if(Utils::isArrayEqual($pattern,$urlRoute)){
52
+            if (Utils::isArrayEqual($pattern, $urlRoute)) {
53 53
                 return $key;
54 54
             }
55 55
         }
@@ -66,26 +66,26 @@  discard block
 block discarded – undo
66 66
      * @param $urlMethod
67 67
      * @return array
68 68
      */
69
-    private static function matchingUrlMethod($patterns,$urlMethod)
69
+    private static function matchingUrlMethod($patterns, $urlMethod)
70 70
     {
71
-        if(isset($urlMethod[0])){
71
+        if (isset($urlMethod[0])) {
72 72
 
73 73
             $list = [];
74 74
 
75
-            foreach ($patterns as $key=>$pattern){
76
-                if(isset($pattern[0])){
77
-                    if($pattern[0] !== $urlMethod[0] && !self::isMatchVaribleRegexPattern($pattern[0])){
75
+            foreach ($patterns as $key=>$pattern) {
76
+                if (isset($pattern[0])) {
77
+                    if ($pattern[0]!==$urlMethod[0] && !self::isMatchVaribleRegexPattern($pattern[0])) {
78 78
                         $list[$key] = [];
79 79
                     }
80 80
                 }
81 81
 
82
-                if(!isset($list[$key])){
82
+                if (!isset($list[$key])) {
83 83
                     $list[$key] = $pattern;
84 84
                 }
85 85
 
86
-                if(isset($pattern[0]) && $pattern[0]==$urlMethod[0]){
86
+                if (isset($pattern[0]) && $pattern[0]==$urlMethod[0]) {
87 87
 
88
-                    if(isset($list[$key-1],$list[$key-1][0]) && $list[$key-1][0]!==$urlMethod[0]){
88
+                    if (isset($list[$key-1], $list[$key-1][0]) && $list[$key-1][0]!==$urlMethod[0]) {
89 89
                         unset($list[$key-1]);
90 90
                     }
91 91
 
@@ -108,53 +108,53 @@  discard block
 block discarded – undo
108 108
     {
109 109
         $routes = self::getRoutes();
110 110
 
111
-        if(!isset($routes['pattern'])){
111
+        if (!isset($routes['pattern'])) {
112 112
             return [];
113 113
         }
114 114
 
115 115
         $patterns = $routes['pattern'];
116
-        $urlRoute = array_filter(route(),'strlen');
116
+        $urlRoute = array_filter(route(), 'strlen');
117 117
 
118 118
         $patternList = [];
119 119
 
120
-        foreach($routes['data'] as $patternKey=>$routeData){
121
-            if($routeData['http']==httpMethod()){
122
-                $patternList[$patternKey]=$patterns[$patternKey];
120
+        foreach ($routes['data'] as $patternKey=>$routeData) {
121
+            if ($routeData['http']==httpMethod()) {
122
+                $patternList[$patternKey] = $patterns[$patternKey];
123 123
             }
124 124
         }
125 125
 
126
-        $patternList = self::matchingUrlMethod($patternList,$urlRoute);
126
+        $patternList = self::matchingUrlMethod($patternList, $urlRoute);
127 127
 
128
-        foreach ($patternList as $key=>$pattern){
128
+        foreach ($patternList as $key=>$pattern) {
129 129
 
130
-            $pattern = array_filter($pattern,'strlen');
131
-            $diff = Arr::arrayDiffKey($pattern,$urlRoute);
130
+            $pattern = array_filter($pattern, 'strlen');
131
+            $diff = Arr::arrayDiffKey($pattern, $urlRoute);
132 132
 
133
-            if($diff){
133
+            if ($diff) {
134 134
 
135 135
                 $matches = true;
136 136
 
137
-                foreach ($pattern as $patternKey=>$patternValue){
138
-                    if(!self::isMatchVaribleRegexPattern($patternValue)){
139
-                        if($patternValue!==$urlRoute[$patternKey]){
137
+                foreach ($pattern as $patternKey=>$patternValue) {
138
+                    if (!self::isMatchVaribleRegexPattern($patternValue)) {
139
+                        if ($patternValue!==$urlRoute[$patternKey]) {
140 140
                             $matches = false;
141 141
                         }
142 142
                     }
143 143
                 }
144 144
 
145
-                if($matches){
145
+                if ($matches) {
146 146
 
147
-                    $isArrayEqual = self::checkArrayEqual($patternList,$urlRoute);
147
+                    $isArrayEqual = self::checkArrayEqual($patternList, $urlRoute);
148 148
 
149
-                    if($isArrayEqual===null){
149
+                    if ($isArrayEqual===null) {
150 150
                         return $key;
151 151
                     }
152 152
                     return $isArrayEqual;
153 153
                 }
154 154
             }
155 155
 
156
-            if(count($pattern)-1 == count(route())){
157
-                if(preg_match('@\{[a-z]+\?\}@is',end($pattern))){
156
+            if (count($pattern)-1==count(route())) {
157
+                if (preg_match('@\{[a-z]+\?\}@is', end($pattern))) {
158 158
                     return $key;
159 159
                 }
160 160
             }
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
         $patternResolve = self::getPatternResolve();
175 175
 
176 176
         //if routes data is available in pattern resolve.
177
-        if(isset($routes['data'][$patternResolve])){
177
+        if (isset($routes['data'][$patternResolve])) {
178 178
 
179 179
             // if the incoming http value is
180 180
             // the same as the real request method, the data is processed.
181
-            if($routes['data'][$patternResolve]['http'] == strtolower(httpMethod)){
181
+            if ($routes['data'][$patternResolve]['http']==strtolower(httpMethod)) {
182 182
 
183 183
                 // we are set the solved pattern to a variable.
184 184
                 $resolve = $routes['data'][$patternResolve];
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     {
204 204
         // we will record the path data for the route.
205 205
         // We set the routeMapper variables and the route path.
206
-        self::setPath(function(){
206
+        self::setPath(function() {
207 207
 
208 208
             // we are sending
209 209
             // the controller and routes.php path.
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
         // in the paths data,
217 217
         // we run the route mapper values ​​and the route files one by one.
218
-        foreach (self::$paths as $mapper=>$controller){
218
+        foreach (self::$paths as $mapper=>$controller) {
219 219
             core()->fileSystem->callFile($mapper);
220 220
         }
221 221
     }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     {
230 230
         $routeDefinitor = call_user_func($callback);
231 231
 
232
-        if(isset($routeDefinitor['controllerPath']) && isset($routeDefinitor['routePath'])){
232
+        if (isset($routeDefinitor['controllerPath']) && isset($routeDefinitor['routePath'])) {
233 233
 
234 234
             //the route paths to be saved to the mappers static property.
235 235
             static::$mappers['routePaths'][] = $routeDefinitor['routePath'];
@@ -237,22 +237,22 @@  discard block
 block discarded – undo
237 237
 
238 238
             // if there is endpoint,
239 239
             // then only that endpoint is transferred into the path
240
-            if(defined('endpoint')){
240
+            if (defined('endpoint')) {
241 241
 
242 242
                 $routeName      = endpoint.'Route.php';
243 243
                 $routeMapper    = $routeDefinitor['routePath'].''.DIRECTORY_SEPARATOR.''.$routeName;
244 244
 
245
-                if(file_exists($routeMapper) && !isset(static::$paths[$routeMapper])){
245
+                if (file_exists($routeMapper) && !isset(static::$paths[$routeMapper])) {
246 246
                     static::$paths[$routeMapper] = $routeDefinitor['controllerPath'];
247 247
                 }
248 248
             }
249
-            else{
249
+            else {
250 250
 
251 251
                 // if there is no endpoint,
252 252
                 // all files in the path of the route are transferred to path.
253 253
                 $allFilesInThatRoutePath = Utils::glob($routeDefinitor['routePath']);
254 254
 
255
-                foreach ($allFilesInThatRoutePath as $item){
255
+                foreach ($allFilesInThatRoutePath as $item) {
256 256
                     static::$paths[$item] = $routeDefinitor['controllerPath'];
257 257
                 }
258 258
             }
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
      * @param $function
267 267
      * @param null $controller
268 268
      */
269
-    public static function setRoute($params,$function,$controller=null)
269
+    public static function setRoute($params, $function, $controller = null)
270 270
     {
271
-        [$pattern,$route]   = $params;
272
-        [$class,$method]    = explode("@",$route);
271
+        [$pattern, $route]   = $params;
272
+        [$class, $method]    = explode("@", $route);
273 273
 
274 274
         $patternList = array_values(
275
-            array_filter(explode("/",$pattern),'strlen')
275
+            array_filter(explode("/", $pattern), 'strlen')
276 276
         );
277 277
 
278 278
         static::$routes['pattern'][] = $patternList;
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
             'http'          => $function,
283 283
             'controller'    => $controller,
284 284
             'namespace'     => static::$namespace,
285
-            'endpoint'      => strtolower(str_replace(StaticPathList::$controllerBundleName,'',static::$namespace))
285
+            'endpoint'      => strtolower(str_replace(StaticPathList::$controllerBundleName, '', static::$namespace))
286 286
         ];
287 287
     }
288 288
 
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
      * @param null $value
293 293
      * @return bool
294 294
      */
295
-    public static function isMatchVaribleRegexPattern($value=null)
295
+    public static function isMatchVaribleRegexPattern($value = null)
296 296
     {
297
-        return (preg_match('@\{(.*?)\}@is',$value)) ? true : false;
297
+        return (preg_match('@\{(.*?)\}@is', $value)) ? true : false;
298 298
     }
299 299
 }
300 300
\ No newline at end of file
Please login to merge, or discard this patch.