Test Setup Failed
Push — master ( 387d88...6e7eb2 )
by Php Easy Api
04:48
created
src/resta/Support/Str.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public static function after($subject, $search)
37 37
     {
38
-        return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
38
+        return $search==='' ? $subject : array_reverse(explode($search, $subject, 2))[0];
39 39
     }
40 40
 
41 41
     /**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $languageSpecific = static::languageSpecificCharsArray($language);
51 51
 
52
-        if (! is_null($languageSpecific)) {
52
+        if (!is_null($languageSpecific)) {
53 53
             $value = str_replace($languageSpecific[0], $languageSpecific[1], $value);
54 54
         }
55 55
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public static function before($subject, $search)
71 71
     {
72
-        return $search === '' ? $subject : explode($search, $subject)[0];
72
+        return $search==='' ? $subject : explode($search, $subject)[0];
73 73
     }
74 74
 
75 75
     /**
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public static function contains($haystack, $needles)
98 98
     {
99
-        foreach ((array) $needles as $needle) {
100
-            if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
99
+        foreach ((array)$needles as $needle) {
100
+            if ($needle!=='' && mb_strpos($haystack, $needle)!==false) {
101 101
                 return true;
102 102
             }
103 103
         }
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public static function endsWith($haystack, $needles)
116 116
     {
117
-        foreach ((array) $needles as $needle) {
118
-            if (mb_substr($haystack, -mb_strlen($needle)) === (string) $needle) {
117
+        foreach ((array)$needles as $needle) {
118
+            if (mb_substr($haystack, -mb_strlen($needle))===(string)$needle) {
119 119
                 return true;
120 120
             }
121 121
         }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public static function is($pattern, $value)
148 148
     {
149
-        $patterns = is_array($pattern) ? $pattern : (array) $pattern;
149
+        $patterns = is_array($pattern) ? $pattern : (array)$pattern;
150 150
 
151 151
         if (empty($patterns)) {
152 152
             return false;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             // If the given value is an exact match we can of course return true right
157 157
             // from the beginning. Otherwise, we will translate asterisks and do an
158 158
             // actual pattern match against the two strings to see if they match.
159
-            if ($pattern == $value) {
159
+            if ($pattern==$value) {
160 160
                 return true;
161 161
             }
162 162
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             // pattern such as "library/*", making any string check convenient.
168 168
             $pattern = str_replace('\*', '.*', $pattern);
169 169
 
170
-            if (preg_match('#^'.$pattern.'\z#u', $value) === 1) {
170
+            if (preg_match('#^'.$pattern.'\z#u', $value)===1) {
171 171
                 return true;
172 172
             }
173 173
         }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public static function limit($value, $limit = 100, $end = '...')
214 214
     {
215
-        if (mb_strwidth($value, 'UTF-8') <= $limit) {
215
+        if (mb_strwidth($value, 'UTF-8')<=$limit) {
216 216
             return $value;
217 217
         }
218 218
 
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
      * @param string $case
239 239
      * @return string
240 240
      */
241
-    public static function crop($value,$crop,$case='lower')
241
+    public static function crop($value, $crop, $case = 'lower')
242 242
     {
243
-        return static::$case(str_replace($crop,'',$value));
243
+        return static::$case(str_replace($crop, '', $value));
244 244
     }
245 245
 
246 246
     /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     {
256 256
         preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
257 257
 
258
-        if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) {
258
+        if (!isset($matches[0]) || static::length($value)===static::length($matches[0])) {
259 259
             return $value;
260 260
         }
261 261
 
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
     {
285 285
         $string = '';
286 286
 
287
-        while (($len = strlen($string)) < $length) {
288
-            $size = $length - $len;
287
+        while (($len = strlen($string))<$length) {
288
+            $size = $length-$len;
289 289
 
290 290
             $bytes = random_bytes($size);
291 291
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
      */
306 306
     public static function replaceWordArray($word, $replace, $subject)
307 307
     {
308
-        if(is_array($word)){
308
+        if (is_array($word)) {
309 309
 
310 310
             foreach ($word as $value) {
311
-                $subject = str_replace($value,$replace,$subject);
311
+                $subject = str_replace($value, $replace, $subject);
312 312
             }
313 313
         }
314 314
 
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
      */
343 343
     public static function replaceFirst($search, $replace, $subject)
344 344
     {
345
-        if ($search == '') {
345
+        if ($search=='') {
346 346
             return $subject;
347 347
         }
348 348
 
349 349
         $position = mb_strpos($subject, $search);
350 350
 
351
-        if ($position !== false) {
352
-            return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position + mb_strlen($search));
351
+        if ($position!==false) {
352
+            return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position+mb_strlen($search));
353 353
         }
354 354
 
355 355
         return $subject;
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
     {
368 368
         $position = mb_strrpos($subject, $search);
369 369
 
370
-        if ($position !== false) {
371
-            return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position + mb_strlen($search));
370
+        if ($position!==false) {
371
+            return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position+mb_strlen($search));
372 372
         }
373 373
 
374 374
         return $subject;
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         $title = static::ascii($title, $language);
424 424
 
425 425
         // Convert all dashes/underscores into separator
426
-        $flip = $separator == '-' ? '_' : '-';
426
+        $flip = $separator=='-' ? '_' : '-';
427 427
 
428 428
         $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
429 429
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             return static::$snakeCache[$key][$delimiter];
455 455
         }
456 456
 
457
-        if (! ctype_lower($value)) {
457
+        if (!ctype_lower($value)) {
458 458
             $value = preg_replace('/\s+/u', '', ucwords($value));
459 459
 
460 460
             $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
      */
473 473
     public static function startsWith($haystack, $needles)
474 474
     {
475
-        foreach ((array) $needles as $needle) {
476
-            if ($needle !== '' && mb_substr($haystack, 0, mb_strlen($needle)) === (string) $needle) {
475
+        foreach ((array)$needles as $needle) {
476
+            if ($needle!=='' && mb_substr($haystack, 0, mb_strlen($needle))===(string)$needle) {
477 477
                 return true;
478 478
             }
479 479
         }
@@ -672,14 +672,14 @@  discard block
 block discarded – undo
672 672
     {
673 673
         static $languageSpecific;
674 674
 
675
-        if (! isset($languageSpecific)) {
675
+        if (!isset($languageSpecific)) {
676 676
             $languageSpecific = [
677 677
                 'bg' => [
678 678
                     ['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'],
679 679
                     ['h', 'H', 'sht', 'SHT', 'a', 'А', 'y', 'Y'],
680 680
                 ],
681 681
                 'de' => [
682
-                    ['ä',  'ö',  'ü',  'Ä',  'Ö',  'Ü'],
682
+                    ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'],
683 683
                     ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'],
684 684
                 ],
685 685
             ];
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
      */
695 695
     public static function slashToBackSlash($data)
696 696
     {
697
-        return str_replace("\\","/",$data);
697
+        return str_replace("\\", "/", $data);
698 698
     }
699 699
 
700 700
     /**
@@ -702,25 +702,25 @@  discard block
 block discarded – undo
702 702
      * @param string $explode
703 703
      * @return array
704 704
      */
705
-    public static function stringToArray($string,$explode=".")
705
+    public static function stringToArray($string, $explode = ".")
706 706
     {
707
-        return explode($explode,$string);
707
+        return explode($explode, $string);
708 708
     }
709 709
 
710 710
     /**
711 711
      * @param null $removeCharacter
712 712
      * @return null|string|string[]
713 713
      */
714
-    public static function removeCharacterFromUri($removeCharacter=null)
714
+    public static function removeCharacterFromUri($removeCharacter = null)
715 715
     {
716
-        if($removeCharacter!==null){
716
+        if ($removeCharacter!==null) {
717 717
             $query = request()->query->all();
718 718
 
719
-            if(count($query)=='1' && isset($query[$removeCharacter])){
720
-                return preg_replace('@'.$removeCharacter.'=(.*)|\?@is','',fullUrl());
719
+            if (count($query)=='1' && isset($query[$removeCharacter])) {
720
+                return preg_replace('@'.$removeCharacter.'=(.*)|\?@is', '', fullUrl());
721 721
             }
722 722
 
723
-            return preg_replace('@'.$removeCharacter.'=\d+\&|\&'.$removeCharacter.'=\d+@is','',fullUrl());
723
+            return preg_replace('@'.$removeCharacter.'=\d+\&|\&'.$removeCharacter.'=\d+@is', '', fullUrl());
724 724
         }
725 725
 
726 726
     }
Please login to merge, or discard this patch.
src/resta/Router/Route.php 1 patch
Spacing   +27 added lines, -27 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
-    public static function checkArrayEqual($patterns,$urlRoute)
46
+    public 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
         }
@@ -69,17 +69,17 @@  discard block
 block discarded – undo
69 69
         // get routes data and the resolving pattern
70 70
         // Both are interrelated.
71 71
         $routes = self::getRoutes();
72
-        $patternResolve = app()->resolve(RouteMatching::class,['route'=>new self()])->getPatternResolve();
72
+        $patternResolve = app()->resolve(RouteMatching::class, ['route'=>new self()])->getPatternResolve();
73 73
 
74 74
         // we set the route variables for the route assistant.
75 75
         self::updateRouteParameters($patternResolve);
76 76
 
77 77
         //if routes data is available in pattern resolve.
78
-        if(isset($routes['data'][$patternResolve])){
78
+        if (isset($routes['data'][$patternResolve])) {
79 79
 
80 80
             // if the incoming http value is
81 81
             // the same as the real request method, the data is processed.
82
-            if($routes['data'][$patternResolve]['http'] == strtolower(httpMethod)){
82
+            if ($routes['data'][$patternResolve]['http']==strtolower(httpMethod)) {
83 83
 
84 84
                 // we are set the solved pattern to a variable.
85 85
                 $resolve = $routes['data'][$patternResolve];
@@ -106,22 +106,22 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $list = [];
108 108
 
109
-        if(isset(static::$routes['pattern'][$patternResolvedKey])){
109
+        if (isset(static::$routes['pattern'][$patternResolvedKey])) {
110 110
 
111 111
             $routeParameters = static::$routes['pattern'][$patternResolvedKey];
112 112
             $route = route();
113 113
 
114
-            foreach($routeParameters as $key=>$param){
114
+            foreach ($routeParameters as $key=>$param) {
115 115
 
116
-                $param = Str::replaceWordArray(['{','}','?'],'',$param);
116
+                $param = Str::replaceWordArray(['{', '}', '?'], '', $param);
117 117
 
118
-                if(isset($route[$key])){
118
+                if (isset($route[$key])) {
119 119
                     $list[$param] = $route[$key];
120 120
                 }
121 121
             }
122 122
         }
123 123
 
124
-        app()->register('routeParams',$list);
124
+        app()->register('routeParams', $list);
125 125
     }
126 126
 
127 127
     /**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         // we will record the path data for the route.
135 135
         // We set the routeMapper variables and the route path.
136
-        self::setPath(function(){
136
+        self::setPath(function() {
137 137
 
138 138
             // we are sending
139 139
             // the controller and routes.php path.
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
         // in the paths data,
147 147
         // we run the route mapper values ​​and the route files one by one.
148
-        foreach (self::$paths as $mapper=>$controller){
148
+        foreach (self::$paths as $mapper=>$controller) {
149 149
             core()->fileSystem->callFile($mapper);
150 150
         }
151 151
     }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $routeDefinitor = call_user_func($callback);
161 161
 
162
-        if(isset($routeDefinitor['controllerPath']) && isset($routeDefinitor['routePath'])){
162
+        if (isset($routeDefinitor['controllerPath']) && isset($routeDefinitor['routePath'])) {
163 163
 
164 164
             //the route paths to be saved to the mappers static property.
165 165
             static::$mappers['routePaths'][] = $routeDefinitor['routePath'];
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
 
168 168
             // if there is endpoint,
169 169
             // then only that endpoint is transferred into the path
170
-            if(defined('endpoint')){
170
+            if (defined('endpoint')) {
171 171
 
172 172
                 $routeName      = endpoint.'Route.php';
173 173
                 $routeMapper    = $routeDefinitor['routePath'].''.DIRECTORY_SEPARATOR.''.$routeName;
174 174
 
175
-                if(file_exists($routeMapper) && !isset(static::$paths[$routeMapper])){
175
+                if (file_exists($routeMapper) && !isset(static::$paths[$routeMapper])) {
176 176
                     static::$paths[$routeMapper] = $routeDefinitor['controllerPath'];
177 177
                 }
178 178
             }
179
-            else{
179
+            else {
180 180
 
181 181
                 // if there is no endpoint,
182 182
                 // all files in the path of the route are transferred to path.
183 183
                 $allFilesInThatRoutePath = Utils::glob($routeDefinitor['routePath']);
184 184
 
185
-                foreach ($allFilesInThatRoutePath as $item){
185
+                foreach ($allFilesInThatRoutePath as $item) {
186 186
                     static::$paths[$item] = $routeDefinitor['controllerPath'];
187 187
                 }
188 188
             }
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
      * @param $function
197 197
      * @param null $controller
198 198
      */
199
-    public static function setRoute($params,$function,$controller=null)
199
+    public static function setRoute($params, $function, $controller = null)
200 200
     {
201
-        [$pattern,$route]   = $params;
202
-        [$class,$method]    = explode("@",$route);
201
+        [$pattern, $route]   = $params;
202
+        [$class, $method]    = explode("@", $route);
203 203
 
204 204
         $patternList = array_values(
205
-            array_filter(explode("/",$pattern),'strlen')
205
+            array_filter(explode("/", $pattern), 'strlen')
206 206
         );
207 207
 
208 208
         static::$routes['pattern'][] = $patternList;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             'http'          => $function,
213 213
             'controller'    => $controller,
214 214
             'namespace'     => static::$namespace,
215
-            'endpoint'      => strtolower(str_replace(StaticPathList::$controllerBundleName,'',static::$namespace))
215
+            'endpoint'      => strtolower(str_replace(StaticPathList::$controllerBundleName, '', static::$namespace))
216 216
         ];
217 217
     }
218 218
 
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
      * @param null $value
223 223
      * @return bool
224 224
      */
225
-    public static function isMatchVaribleRegexPattern($value=null)
225
+    public static function isMatchVaribleRegexPattern($value = null)
226 226
     {
227 227
         // determines if the variable that can be used
228 228
         // in the route file meets the regex rule.
229
-        return (preg_match('@\{(.*?)\}@is',$value)) ? true : false;
229
+        return (preg_match('@\{(.*?)\}@is', $value)) ? true : false;
230 230
     }
231 231
 
232 232
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
      * @param null $value
237 237
      * @return bool
238 238
      */
239
-    public static function isOptionalVaribleRegexPattern($value=null)
239
+    public static function isOptionalVaribleRegexPattern($value = null)
240 240
     {
241 241
         // determines if the variable that can be used
242 242
         // in the route file meets the regex rule.
243
-        return preg_match('@\{[a-z]+\?\}@is',$value) ? true : false;
243
+        return preg_match('@\{[a-z]+\?\}@is', $value) ? true : false;
244 244
     }
245 245
 
246 246
 
Please login to merge, or discard this patch.
src/resta/Container/GraceContainer.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @throws \ReflectionException
50 50
      */
51
-    protected function getNameContainers($parameter,$param)
51
+    protected function getNameContainers($parameter, $param)
52 52
     {
53 53
         // If the parameter contains a route variable.
54 54
         // We do a custom bind for the route
55
-        if($this->checkNameContainer($parameter)){
55
+        if ($this->checkNameContainer($parameter)) {
56 56
 
57 57
             // we do the name control for the container here,
58 58
             // and if we have the name container we are checking, we make a handle make bind.
59 59
             $nameContainers = $this->nameContainers[$parameter->getName()];
60
-            return app()->resolve($nameContainers,[
60
+            return app()->resolve($nameContainers, [
61 61
                 'reflection' => $this->reflection
62
-            ])->resolveContainer($parameter->getDefaultValue(),$param);
62
+            ])->resolveContainer($parameter->getDefaultValue(), $param);
63 63
         }
64 64
 
65 65
         return [];
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @throws \ReflectionException
74 74
      */
75
-    public function graceContainerBuilder($parameter,$param)
75
+    public function graceContainerBuilder($parameter, $param)
76 76
     {
77 77
         // if the parameter is an object
78 78
         // but not a container object.
79 79
         // we do some useful logic bind for user benefit.
80
-        if($parameter->getType()!==null){
81
-            return app()->resolve(RepositoryContainer::class)->handle($parameter,$param);
80
+        if ($parameter->getType()!==null) {
81
+            return app()->resolve(RepositoryContainer::class)->handle($parameter, $param);
82 82
         }
83 83
 
84 84
         // In particular, name container values can be specified and
85 85
         // they are injected directly into the methods contextually.
86
-        return $this->getNameContainers($parameter,$param);
86
+        return $this->getNameContainers($parameter, $param);
87 87
     }
88 88
 }
89 89
\ No newline at end of file
Please login to merge, or discard this patch.