Test Setup Failed
Push — master ( 6c96c6...47635f )
by Php Easy Api
03:49
created
src/resta/Support/Utils.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
      * @param null $class
28 28
      * @return mixed
29 29
      */
30
-    public static function resolve($class=null)
30
+    public static function resolve($class = null)
31 31
     {
32 32
         //class resolve
33
-        if($class!==null){
33
+        if ($class!==null) {
34 34
             $container = self::callBuild();
35 35
             return $container->get($class);
36 36
         }
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
      * @param bool $shift
44 44
      * @return array
45 45
      */
46
-    public static function upperCase($argument,$shift=true)
46
+    public static function upperCase($argument, $shift = true)
47 47
     {
48
-        if($shift){
48
+        if ($shift) {
49 49
             array_shift($argument);
50 50
         }
51 51
 
52
-        return array_map(function($argument){
52
+        return array_map(function($argument) {
53 53
             return ucfirst($argument);
54 54
         },$argument);
55 55
     }
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function strtolower($argument)
75 75
     {
76
-        if(!is_array($argument)){
76
+        if (!is_array($argument)) {
77 77
             return strtolower($argument);
78 78
         }
79
-        return array_map(function($argument){
79
+        return array_map(function($argument) {
80 80
             return strtolower($argument);
81 81
         },$argument);
82 82
     }
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      * @param array $data
86 86
      * @return string
87 87
      */
88
-    public static function generatorNamespace($data=array())
88
+    public static function generatorNamespace($data = array())
89 89
     {
90
-        return str_replace('.php','',implode("\\",$data));
90
+        return str_replace('.php', '', implode("\\", $data));
91 91
     }
92 92
 
93 93
     /**
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
      * @param bool $extension
96 96
      * @return mixed
97 97
      */
98
-    public static function getPathFromNamespace($class,$extension=true)
98
+    public static function getPathFromNamespace($class, $extension = true)
99 99
     {
100
-        if($extension){
101
-            $default=root.'/'.str_replace("\\","/",$class).'.php';
100
+        if ($extension) {
101
+            $default = root.'/'.str_replace("\\", "/", $class).'.php';
102 102
         }
103
-        else{
104
-            $default=root.'/'.str_replace("\\","/",$class).'';
103
+        else {
104
+            $default = root.'/'.str_replace("\\", "/", $class).'';
105 105
         }
106 106
 
107
-        return str_replace("/App",'/src/app',$default);
107
+        return str_replace("/App", '/src/app', $default);
108 108
     }
109 109
 
110 110
     /**
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
      * @param $method
122 122
      * @return bool
123 123
      */
124
-    public static function existMethod($class,$method)
124
+    public static function existMethod($class, $method)
125 125
     {
126
-        return method_exists($class,$method);
126
+        return method_exists($class, $method);
127 127
     }
128 128
 
129 129
     /**
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
      * @param $second
132 132
      * @return bool
133 133
      */
134
-    public static function isArrayEqual($first,$second)
134
+    public static function isArrayEqual($first, $second)
135 135
     {
136
-        return (count( $first ) == count( $second ) && !array_diff( $first, $second ));
136
+        return (count($first)==count($second) && !array_diff($first, $second));
137 137
     }
138 138
 
139 139
     /**
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
      * @param bool $filename
151 151
      * @return array
152 152
      */
153
-    public static function glob($path,$filename=false)
153
+    public static function glob($path, $filename = false)
154 154
     {
155 155
         $configList = [];
156 156
 
157 157
         foreach (glob($path.'/*.php') as $config) {
158 158
 
159
-            $configArray=str_replace(".php","",explode("/",$config));
160
-            $configList[end($configArray)]=$config;
159
+            $configArray = str_replace(".php", "", explode("/", $config));
160
+            $configList[end($configArray)] = $config;
161 161
         }
162 162
 
163
-        if($filename===true){
163
+        if ($filename===true) {
164 164
             return array_keys($configList);
165 165
         }
166 166
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      * @param string $seperator
190 190
      * @return mixed
191 191
      */
192
-    public static function getJustClassName($namespace,$seperator="\\")
192
+    public static function getJustClassName($namespace, $seperator = "\\")
193 193
     {
194 194
         $path = explode($seperator, $namespace);
195 195
         return array_pop($path);
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
      * @param array $param
201 201
      * @return bool
202 202
      */
203
-    public static function changeClass($class,$param=array())
203
+    public static function changeClass($class, $param = array())
204 204
     {
205
-        $executionPath=$class;
205
+        $executionPath = $class;
206 206
         $dt = fopen($executionPath, "r");
207 207
         $content = fread($dt, filesize($executionPath));
208 208
         fclose($dt);
209 209
 
210
-        foreach ($param as $key=>$value){
211
-            $content=str_replace($key,$value,$content);
210
+        foreach ($param as $key=>$value) {
211
+            $content = str_replace($key, $value, $content);
212 212
         }
213 213
 
214 214
         $dt = fopen($executionPath, "w");
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
      * @param $callback
224 224
      * @return mixed
225 225
      */
226
-    public static function returnCallback($data,$callback)
226
+    public static function returnCallback($data, $callback)
227 227
     {
228
-        return call_user_func_array($callback,[$data]);
228
+        return call_user_func_array($callback, [$data]);
229 229
     }
230 230
 
231 231
     /**
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
      */
235 235
     public static function getNamespace($namespace)
236 236
     {
237
-        $rootDelete=str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'','',$namespace);
237
+        $rootDelete = str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'', '', $namespace);
238 238
 
239 239
         return 'App\\'.self::generatorNamespace(
240
-                explode(''.DIRECTORY_SEPARATOR.'',$rootDelete)
240
+                explode(''.DIRECTORY_SEPARATOR.'', $rootDelete)
241 241
             );
242 242
 
243 243
     }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      */
249 249
     public static function callbackProcess($callback)
250 250
     {
251
-        return (is_callable($callback)) ? call_user_func_array($callback,[app()]) : $callback;
251
+        return (is_callable($callback)) ? call_user_func_array($callback, [app()]) : $callback;
252 252
     }
253 253
 
254 254
     /**
@@ -256,29 +256,29 @@  discard block
 block discarded – undo
256 256
      * @param $array2
257 257
      * @return bool
258 258
      */
259
-    public static function array_diff_key_recursive ($array1, $array2)
259
+    public static function array_diff_key_recursive($array1, $array2)
260 260
     {
261
-        if(count($array1)!==count($array2)) self::$bool[]=false;
261
+        if (count($array1)!==count($array2)) self::$bool[] = false;
262 262
 
263
-        foreach ($array1 as $array1_key=>$array1_value){
263
+        foreach ($array1 as $array1_key=>$array1_value) {
264 264
 
265
-            if(!is_array($array1_value)){
266
-                if(!array_key_exists($array1_key,$array2)) self::$bool[]=false;
265
+            if (!is_array($array1_value)) {
266
+                if (!array_key_exists($array1_key, $array2)) self::$bool[] = false;
267 267
             }
268
-            else{
269
-                if(!array_key_exists($array1_key,$array2)) self::$bool[]=false;
268
+            else {
269
+                if (!array_key_exists($array1_key, $array2)) self::$bool[] = false;
270 270
 
271
-                if(!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key]=[];
271
+                if (!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key] = [];
272 272
 
273
-                if(isset($array1_value[0])) $array1_value=$array1_value[0];
273
+                if (isset($array1_value[0])) $array1_value = $array1_value[0];
274 274
 
275
-                if(isset($array2[$array1_key][0])) $array2[$array1_key]=$array2[$array1_key][0];
275
+                if (isset($array2[$array1_key][0])) $array2[$array1_key] = $array2[$array1_key][0];
276 276
 
277
-                self::array_diff_key_recursive($array1_value,$array2[$array1_key]);
277
+                self::array_diff_key_recursive($array1_value, $array2[$array1_key]);
278 278
             }
279 279
         }
280 280
 
281
-        if(in_array(false,self::$bool)){
281
+        if (in_array(false, self::$bool)) {
282 282
             return false;
283 283
         }
284 284
         return true;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public static function slashToBackSlash($data)
292 292
     {
293
-        return str_replace("/","\\",$data);
293
+        return str_replace("/", "\\", $data);
294 294
     }
295 295
 
296 296
     /**
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
      * @param null $key
299 299
      * @return null
300 300
      */
301
-    public static function trace($debug=0,$key=null)
301
+    public static function trace($debug = 0, $key = null)
302 302
     {
303
-        $trace=debug_backtrace();
303
+        $trace = debug_backtrace();
304 304
 
305
-        if($key===null){
305
+        if ($key===null) {
306 306
             return $trace[$debug] ?? null;
307 307
         }
308 308
         return $trace[$debug][$key] ?? null;
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
     public  static function chmod_r($dir, $dirPermissions, $filePermissions)
318 318
     {
319 319
         $dp = opendir($dir);
320
-        while($file = readdir($dp)) {
321
-            if (($file == ".") || ($file == ".."))
320
+        while ($file = readdir($dp)) {
321
+            if (($file==".") || ($file==".."))
322 322
                 continue;
323 323
 
324 324
             $fullPath = $dir."/".$file;
325 325
 
326
-            if(is_dir($fullPath)) {
326
+            if (is_dir($fullPath)) {
327 327
                 chmod($fullPath, $dirPermissions);
328 328
                 self::chmod_r($fullPath, $dirPermissions, $filePermissions);
329 329
             } else {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      */
340 340
     public static function getServiceConf()
341 341
     {
342
-        if(property_exists(core(),'serviceConf') && defined('methodName')){
342
+        if (property_exists(core(), 'serviceConf') && defined('methodName')) {
343 343
             return core()->serviceConf;
344 344
         }
345 345
         return [];
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
      */
356 356
     public static function getAllFilesInDirectory($dir, $recursive = true, $basedir = '', $include_dirs = false)
357 357
     {
358
-        if ($dir == '') {return array();} else {$results = array(); $subresults = array();}
359
-        if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent
360
-        if ($basedir == '') {$basedir = realpath($dir).DIRECTORY_SEPARATOR;}
358
+        if ($dir=='') {return array(); } else {$results = array(); $subresults = array(); }
359
+        if (!is_dir($dir)) {$dir = dirname($dir); } // so a files path can be sent
360
+        if ($basedir=='') {$basedir = realpath($dir).DIRECTORY_SEPARATOR; }
361 361
 
362 362
         $files = scandir($dir);
363
-        foreach ($files as $key => $value){
364
-            if ( ($value != '.') && ($value != '..') ) {
363
+        foreach ($files as $key => $value) {
364
+            if (($value!='.') && ($value!='..')) {
365 365
                 $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
366 366
                 if (is_dir($path)) {
367 367
                     // optionally include directories in file list
368
-                    if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path);}
368
+                    if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path); }
369 369
                     // optionally get file list for all subdirectories
370 370
                     if ($recursive) {
371 371
                         $subdirresults = self::getAllFilesInDirectory($path, $recursive, $basedir, $include_dirs);
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             }
379 379
         }
380 380
         // merge the subarray to give the list of files then subdirectory files
381
-        if (count($subresults) > 0) {$results = array_merge($subresults, $results);}
381
+        if (count($subresults)>0) {$results = array_merge($subresults, $results); }
382 382
         return $results;
383 383
     }
384 384
 
@@ -387,18 +387,18 @@  discard block
 block discarded – undo
387 387
      * @param null $reelPath
388 388
      * @return array
389 389
      */
390
-    public static function getPathWithPhpExtension($files,$reelPath=null)
390
+    public static function getPathWithPhpExtension($files, $reelPath = null)
391 391
     {
392 392
         $pathWithPhpList = [];
393 393
 
394
-        foreach ($files as $file){
394
+        foreach ($files as $file) {
395 395
 
396
-            if(preg_match('@(.*).php@is',$file,$pathWithPhp)){
396
+            if (preg_match('@(.*).php@is', $file, $pathWithPhp)) {
397 397
 
398
-                if($reelPath===null){
398
+                if ($reelPath===null) {
399 399
                     $pathWithPhpList[] = $pathWithPhp[0];
400 400
                 }
401
-                else{
401
+                else {
402 402
                     $pathWithPhpList[] = $reelPath.'/'.$pathWithPhp[0];
403 403
                 }
404 404
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
      */
432 432
     public static function resolverClass($class)
433 433
     {
434
-        if(self::isNamespaceExists($class)){
434
+        if (self::isNamespaceExists($class)) {
435 435
             return app()->resolve($class);
436 436
         }
437 437
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
      */
444 444
     public static function getRequestPathInfo()
445 445
     {
446
-        if(is_null(BootStaticManager::getRequestPath())){
447
-            return explode("/",request()->getPathInfo());
446
+        if (is_null(BootStaticManager::getRequestPath())) {
447
+            return explode("/", request()->getPathInfo());
448 448
         }
449 449
         return BootStaticManager::getRequestPath();
450 450
     }
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
      * @param null $remove
455 455
      * @return array
456 456
      */
457
-    public static function removeTrace($trace,$remove=null)
457
+    public static function removeTrace($trace, $remove = null)
458 458
     {
459 459
         $list = [];
460 460
 
461
-        foreach($trace as $key=>$item){
461
+        foreach ($trace as $key=>$item) {
462 462
 
463
-            if(isset($item['file']) && !preg_match('@'.$remove.'@',$item['file'])){
463
+            if (isset($item['file']) && !preg_match('@'.$remove.'@', $item['file'])) {
464 464
                 $list[$key] = $item;
465 465
             }
466 466
         }
Please login to merge, or discard this patch.