@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param bool $shift |
17 | 17 | * @return array |
18 | 18 | */ |
19 | - public static function upperCase($argument,$shift=true) |
|
19 | + public static function upperCase($argument, $shift = true) |
|
20 | 20 | { |
21 | - if($shift){ |
|
21 | + if ($shift) { |
|
22 | 22 | array_shift($argument); |
23 | 23 | } |
24 | 24 | |
25 | - return array_map(function($argument){ |
|
25 | + return array_map(function($argument) { |
|
26 | 26 | return ucfirst($argument); |
27 | 27 | },$argument); |
28 | 28 | } |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public static function strtolower($argument) |
48 | 48 | { |
49 | - if(!is_array($argument)){ |
|
49 | + if (!is_array($argument)) { |
|
50 | 50 | return strtolower($argument); |
51 | 51 | } |
52 | - return array_map(function($argument){ |
|
52 | + return array_map(function($argument) { |
|
53 | 53 | return strtolower($argument); |
54 | 54 | },$argument); |
55 | 55 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @param array $data |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - public static function generatorNamespace($data=array()) |
|
61 | + public static function generatorNamespace($data = array()) |
|
62 | 62 | { |
63 | - return str_replace('.php','',implode("\\",$data)); |
|
63 | + return str_replace('.php', '', implode("\\", $data)); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | * @param bool $extension |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public static function getPathFromNamespace($class,$extension=true) |
|
71 | + public static function getPathFromNamespace($class, $extension = true) |
|
72 | 72 | { |
73 | - if($extension){ |
|
74 | - $default=root.'/'.str_replace("\\","/",$class).'.php'; |
|
73 | + if ($extension) { |
|
74 | + $default = root.'/'.str_replace("\\", "/", $class).'.php'; |
|
75 | 75 | } |
76 | - else{ |
|
77 | - $default=root.'/'.str_replace("\\","/",$class).''; |
|
76 | + else { |
|
77 | + $default = root.'/'.str_replace("\\", "/", $class).''; |
|
78 | 78 | } |
79 | 79 | |
80 | - return str_replace("/App",'/src/app',$default); |
|
80 | + return str_replace("/App", '/src/app', $default); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param $method |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | - public static function existMethod($class,$method) |
|
97 | + public static function existMethod($class, $method) |
|
98 | 98 | { |
99 | - return method_exists($class,$method); |
|
99 | + return method_exists($class, $method); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @param $second |
105 | 105 | * @return bool |
106 | 106 | */ |
107 | - public static function isArrayEqual($first,$second) |
|
107 | + public static function isArrayEqual($first, $second) |
|
108 | 108 | { |
109 | - return (count( $first ) == count( $second ) && !array_diff( $first, $second )); |
|
109 | + return (count($first)==count($second) && !array_diff($first, $second)); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | * @param bool $filename |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - public static function glob($path,$filename=false) |
|
126 | + public static function glob($path, $filename = false) |
|
127 | 127 | { |
128 | 128 | $configList = []; |
129 | 129 | |
130 | 130 | foreach (glob($path.'/*.php') as $config) { |
131 | 131 | |
132 | - $configArray=str_replace(".php","",explode("/",$config)); |
|
133 | - $configList[end($configArray)]=$config; |
|
132 | + $configArray = str_replace(".php", "", explode("/", $config)); |
|
133 | + $configList[end($configArray)] = $config; |
|
134 | 134 | } |
135 | 135 | |
136 | - if($filename===true){ |
|
136 | + if ($filename===true) { |
|
137 | 137 | return array_keys($configList); |
138 | 138 | } |
139 | 139 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $seperator |
163 | 163 | * @return mixed |
164 | 164 | */ |
165 | - public static function getJustClassName($namespace,$seperator="\\") |
|
165 | + public static function getJustClassName($namespace, $seperator = "\\") |
|
166 | 166 | { |
167 | 167 | $path = explode($seperator, $namespace); |
168 | 168 | return array_pop($path); |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | * @param array $param |
174 | 174 | * @return bool |
175 | 175 | */ |
176 | - public static function changeClass($class,$param=array()) |
|
176 | + public static function changeClass($class, $param = array()) |
|
177 | 177 | { |
178 | - $executionPath=$class; |
|
178 | + $executionPath = $class; |
|
179 | 179 | $dt = fopen($executionPath, "r"); |
180 | 180 | $content = fread($dt, filesize($executionPath)); |
181 | 181 | fclose($dt); |
182 | 182 | |
183 | - foreach ($param as $key=>$value){ |
|
184 | - $content=str_replace($key,$value,$content); |
|
183 | + foreach ($param as $key=>$value) { |
|
184 | + $content = str_replace($key, $value, $content); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $dt = fopen($executionPath, "w"); |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * @param $callback |
197 | 197 | * @return mixed |
198 | 198 | */ |
199 | - public static function returnCallback($data,$callback) |
|
199 | + public static function returnCallback($data, $callback) |
|
200 | 200 | { |
201 | - return call_user_func_array($callback,[$data]); |
|
201 | + return call_user_func_array($callback, [$data]); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public static function getNamespace($namespace) |
209 | 209 | { |
210 | - $rootDelete=str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'','',$namespace); |
|
210 | + $rootDelete = str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'', '', $namespace); |
|
211 | 211 | |
212 | 212 | return 'App\\'.self::generatorNamespace( |
213 | - explode(''.DIRECTORY_SEPARATOR.'',$rootDelete) |
|
213 | + explode(''.DIRECTORY_SEPARATOR.'', $rootDelete) |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public static function callbackProcess($callback) |
223 | 223 | { |
224 | - return (is_callable($callback)) ? call_user_func_array($callback,[app()]) : $callback; |
|
224 | + return (is_callable($callback)) ? call_user_func_array($callback, [app()]) : $callback; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -229,29 +229,29 @@ discard block |
||
229 | 229 | * @param $array2 |
230 | 230 | * @return bool |
231 | 231 | */ |
232 | - public static function array_diff_key_recursive ($array1, $array2) |
|
232 | + public static function array_diff_key_recursive($array1, $array2) |
|
233 | 233 | { |
234 | - if(count($array1)!==count($array2)) self::$bool[]=false; |
|
234 | + if (count($array1)!==count($array2)) self::$bool[] = false; |
|
235 | 235 | |
236 | - foreach ($array1 as $array1_key=>$array1_value){ |
|
236 | + foreach ($array1 as $array1_key=>$array1_value) { |
|
237 | 237 | |
238 | - if(!is_array($array1_value)){ |
|
239 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
238 | + if (!is_array($array1_value)) { |
|
239 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
240 | 240 | } |
241 | - else{ |
|
242 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
241 | + else { |
|
242 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
243 | 243 | |
244 | - if(!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key]=[]; |
|
244 | + if (!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key] = []; |
|
245 | 245 | |
246 | - if(isset($array1_value[0])) $array1_value=$array1_value[0]; |
|
246 | + if (isset($array1_value[0])) $array1_value = $array1_value[0]; |
|
247 | 247 | |
248 | - if(isset($array2[$array1_key][0])) $array2[$array1_key]=$array2[$array1_key][0]; |
|
248 | + if (isset($array2[$array1_key][0])) $array2[$array1_key] = $array2[$array1_key][0]; |
|
249 | 249 | |
250 | - self::array_diff_key_recursive($array1_value,$array2[$array1_key]); |
|
250 | + self::array_diff_key_recursive($array1_value, $array2[$array1_key]); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - if(in_array(false,self::$bool)){ |
|
254 | + if (in_array(false, self::$bool)) { |
|
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | return true; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public static function slashToBackSlash($data) |
265 | 265 | { |
266 | - return str_replace("/","\\",$data); |
|
266 | + return str_replace("/", "\\", $data); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | * @param null $key |
272 | 272 | * @return null |
273 | 273 | */ |
274 | - public static function trace($debug=0,$key=null) |
|
274 | + public static function trace($debug = 0, $key = null) |
|
275 | 275 | { |
276 | - $trace=debug_backtrace(); |
|
276 | + $trace = debug_backtrace(); |
|
277 | 277 | |
278 | - if($key===null){ |
|
278 | + if ($key===null) { |
|
279 | 279 | return $trace[$debug] ?? null; |
280 | 280 | } |
281 | 281 | return $trace[$debug][$key] ?? null; |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | public static function chmod_r($dir, $dirPermissions, $filePermissions) |
291 | 291 | { |
292 | 292 | $dp = opendir($dir); |
293 | - while($file = readdir($dp)) { |
|
294 | - if (($file == ".") || ($file == "..")) |
|
293 | + while ($file = readdir($dp)) { |
|
294 | + if (($file==".") || ($file=="..")) |
|
295 | 295 | continue; |
296 | 296 | |
297 | 297 | $fullPath = $dir."/".$file; |
298 | 298 | |
299 | - if(is_dir($fullPath)) { |
|
299 | + if (is_dir($fullPath)) { |
|
300 | 300 | chmod($fullPath, $dirPermissions); |
301 | 301 | self::chmod_r($fullPath, $dirPermissions, $filePermissions); |
302 | 302 | } else { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public static function getServiceConf() |
314 | 314 | { |
315 | - if(property_exists(core(),'serviceConf') && defined('methodName')){ |
|
315 | + if (property_exists(core(), 'serviceConf') && defined('methodName')) { |
|
316 | 316 | return core()->serviceConf; |
317 | 317 | } |
318 | 318 | return []; |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | */ |
329 | 329 | public static function getAllFilesInDirectory($dir, $recursive = true, $basedir = '', $include_dirs = false) |
330 | 330 | { |
331 | - if ($dir == '') {return array();} else {$results = array(); $subresults = array();} |
|
332 | - if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent |
|
333 | - if ($basedir == '') {$basedir = realpath($dir).DIRECTORY_SEPARATOR;} |
|
331 | + if ($dir=='') {return array(); } else {$results = array(); $subresults = array(); } |
|
332 | + if (!is_dir($dir)) {$dir = dirname($dir); } // so a files path can be sent |
|
333 | + if ($basedir=='') {$basedir = realpath($dir).DIRECTORY_SEPARATOR; } |
|
334 | 334 | |
335 | 335 | $files = scandir($dir); |
336 | - foreach ($files as $key => $value){ |
|
337 | - if ( ($value != '.') && ($value != '..') ) { |
|
336 | + foreach ($files as $key => $value) { |
|
337 | + if (($value!='.') && ($value!='..')) { |
|
338 | 338 | $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
339 | 339 | if (is_dir($path)) { |
340 | 340 | // optionally include directories in file list |
341 | - if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path);} |
|
341 | + if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path); } |
|
342 | 342 | // optionally get file list for all subdirectories |
343 | 343 | if ($recursive) { |
344 | 344 | $subdirresults = self::getAllFilesInDirectory($path, $recursive, $basedir, $include_dirs); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | // merge the subarray to give the list of files then subdirectory files |
354 | - if (count($subresults) > 0) {$results = array_merge($subresults, $results);} |
|
354 | + if (count($subresults)>0) {$results = array_merge($subresults, $results); } |
|
355 | 355 | return $results; |
356 | 356 | } |
357 | 357 | |
@@ -360,18 +360,18 @@ discard block |
||
360 | 360 | * @param null $reelPath |
361 | 361 | * @return array |
362 | 362 | */ |
363 | - public static function getPathWithPhpExtension($files,$reelPath=null) |
|
363 | + public static function getPathWithPhpExtension($files, $reelPath = null) |
|
364 | 364 | { |
365 | 365 | $pathWithPhpList = []; |
366 | 366 | |
367 | - foreach ($files as $file){ |
|
367 | + foreach ($files as $file) { |
|
368 | 368 | |
369 | - if(preg_match('@(.*).php@is',$file,$pathWithPhp)){ |
|
369 | + if (preg_match('@(.*).php@is', $file, $pathWithPhp)) { |
|
370 | 370 | |
371 | - if($reelPath===null){ |
|
371 | + if ($reelPath===null) { |
|
372 | 372 | $pathWithPhpList[] = $pathWithPhp[0]; |
373 | 373 | } |
374 | - else{ |
|
374 | + else { |
|
375 | 375 | $pathWithPhpList[] = $reelPath.'/'.$pathWithPhp[0]; |
376 | 376 | } |
377 | 377 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | */ |
405 | 405 | public static function resolverClass($class) |
406 | 406 | { |
407 | - if(self::isNamespaceExists($class)){ |
|
407 | + if (self::isNamespaceExists($class)) { |
|
408 | 408 | return app()->resolve($class); |
409 | 409 | } |
410 | 410 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | */ |
417 | 417 | public static function getRequestPathInfo() |
418 | 418 | { |
419 | - if(is_null(BootStaticManager::getRequestPath())){ |
|
420 | - return explode("/",request()->getPathInfo()); |
|
419 | + if (is_null(BootStaticManager::getRequestPath())) { |
|
420 | + return explode("/", request()->getPathInfo()); |
|
421 | 421 | } |
422 | 422 | return BootStaticManager::getRequestPath(); |
423 | 423 | } |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | * @param null $remove |
428 | 428 | * @return array |
429 | 429 | */ |
430 | - public static function removeTrace($trace,$remove=null) |
|
430 | + public static function removeTrace($trace, $remove = null) |
|
431 | 431 | { |
432 | 432 | $list = []; |
433 | 433 | |
434 | - foreach($trace as $key=>$item){ |
|
434 | + foreach ($trace as $key=>$item) { |
|
435 | 435 | |
436 | - if(isset($item['file']) && !preg_match('@'.$remove.'@',$item['file'])){ |
|
436 | + if (isset($item['file']) && !preg_match('@'.$remove.'@', $item['file'])) { |
|
437 | 437 | $list[$key] = $item; |
438 | 438 | } |
439 | 439 | } |