@@ -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,18 +173,18 @@ 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 | |
181 | - if($dt!==false){ |
|
181 | + if ($dt!==false) { |
|
182 | 182 | |
183 | 183 | $content = fread($dt, filesize($executionPath)); |
184 | 184 | fclose($dt); |
185 | 185 | |
186 | - foreach ($param as $key=>$value){ |
|
187 | - $content=str_replace($key,$value,$content); |
|
186 | + foreach ($param as $key=>$value) { |
|
187 | + $content = str_replace($key, $value, $content); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $dt = fopen($executionPath, "w"); |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | * @param $callback |
203 | 203 | * @return mixed |
204 | 204 | */ |
205 | - public static function returnCallback($data,$callback) |
|
205 | + public static function returnCallback($data, $callback) |
|
206 | 206 | { |
207 | - return call_user_func_array($callback,[$data]); |
|
207 | + return call_user_func_array($callback, [$data]); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public static function getNamespace($namespace) |
215 | 215 | { |
216 | - $rootDelete=str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'','',$namespace); |
|
216 | + $rootDelete = str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'', '', $namespace); |
|
217 | 217 | |
218 | 218 | return 'App\\'.self::generatorNamespace( |
219 | - explode(''.DIRECTORY_SEPARATOR.'',$rootDelete) |
|
219 | + explode(''.DIRECTORY_SEPARATOR.'', $rootDelete) |
|
220 | 220 | ); |
221 | 221 | |
222 | 222 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public static function callbackProcess($callback) |
229 | 229 | { |
230 | - return (is_callable($callback)) ? call_user_func_array($callback,[app()]) : $callback; |
|
230 | + return (is_callable($callback)) ? call_user_func_array($callback, [app()]) : $callback; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -235,29 +235,29 @@ discard block |
||
235 | 235 | * @param $array2 |
236 | 236 | * @return bool |
237 | 237 | */ |
238 | - public static function array_diff_key_recursive ($array1, $array2) |
|
238 | + public static function array_diff_key_recursive($array1, $array2) |
|
239 | 239 | { |
240 | - if(count($array1)!==count($array2)) self::$bool[]=false; |
|
240 | + if (count($array1)!==count($array2)) self::$bool[] = false; |
|
241 | 241 | |
242 | - foreach ($array1 as $array1_key=>$array1_value){ |
|
242 | + foreach ($array1 as $array1_key=>$array1_value) { |
|
243 | 243 | |
244 | - if(!is_array($array1_value)){ |
|
245 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
244 | + if (!is_array($array1_value)) { |
|
245 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
246 | 246 | } |
247 | - else{ |
|
248 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
247 | + else { |
|
248 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
249 | 249 | |
250 | - if(!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key]=[]; |
|
250 | + if (!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key] = []; |
|
251 | 251 | |
252 | - if(isset($array1_value[0])) $array1_value=$array1_value[0]; |
|
252 | + if (isset($array1_value[0])) $array1_value = $array1_value[0]; |
|
253 | 253 | |
254 | - if(isset($array2[$array1_key][0])) $array2[$array1_key]=$array2[$array1_key][0]; |
|
254 | + if (isset($array2[$array1_key][0])) $array2[$array1_key] = $array2[$array1_key][0]; |
|
255 | 255 | |
256 | - self::array_diff_key_recursive($array1_value,$array2[$array1_key]); |
|
256 | + self::array_diff_key_recursive($array1_value, $array2[$array1_key]); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - if(in_array(false,self::$bool)){ |
|
260 | + if (in_array(false, self::$bool)) { |
|
261 | 261 | return false; |
262 | 262 | } |
263 | 263 | return true; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | public static function slashToBackSlash($data) |
271 | 271 | { |
272 | - return str_replace("/","\\",$data); |
|
272 | + return str_replace("/", "\\", $data); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | * @param null $key |
278 | 278 | * @return null |
279 | 279 | */ |
280 | - public static function trace($debug=0,$key=null) |
|
280 | + public static function trace($debug = 0, $key = null) |
|
281 | 281 | { |
282 | - $trace=debug_backtrace(); |
|
282 | + $trace = debug_backtrace(); |
|
283 | 283 | |
284 | - if($key===null){ |
|
284 | + if ($key===null) { |
|
285 | 285 | return $trace[$debug] ?? null; |
286 | 286 | } |
287 | 287 | return $trace[$debug][$key] ?? null; |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | public static function chmod_r($dir, $dirPermissions, $filePermissions) |
297 | 297 | { |
298 | 298 | $dp = opendir($dir); |
299 | - while($file = readdir($dp)) { |
|
300 | - if (($file == ".") || ($file == "..")) |
|
299 | + while ($file = readdir($dp)) { |
|
300 | + if (($file==".") || ($file=="..")) |
|
301 | 301 | continue; |
302 | 302 | |
303 | 303 | $fullPath = $dir."/".$file; |
304 | 304 | |
305 | - if(is_dir($fullPath)) { |
|
305 | + if (is_dir($fullPath)) { |
|
306 | 306 | chmod($fullPath, $dirPermissions); |
307 | 307 | self::chmod_r($fullPath, $dirPermissions, $filePermissions); |
308 | 308 | } else { |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public static function getServiceConf() |
320 | 320 | { |
321 | - if(property_exists(core(),'serviceConf') && defined('methodName')){ |
|
321 | + if (property_exists(core(), 'serviceConf') && defined('methodName')) { |
|
322 | 322 | return core()->serviceConf; |
323 | 323 | } |
324 | 324 | return []; |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public static function getAllFilesInDirectory($dir, $recursive = true, $basedir = '', $include_dirs = false) |
336 | 336 | { |
337 | - if ($dir == '') {return array();} else {$results = array(); $subresults = array();} |
|
338 | - if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent |
|
339 | - if ($basedir == '') {$basedir = realpath($dir).DIRECTORY_SEPARATOR;} |
|
337 | + if ($dir=='') {return array(); } else {$results = array(); $subresults = array(); } |
|
338 | + if (!is_dir($dir)) {$dir = dirname($dir); } // so a files path can be sent |
|
339 | + if ($basedir=='') {$basedir = realpath($dir).DIRECTORY_SEPARATOR; } |
|
340 | 340 | |
341 | 341 | $files = scandir($dir); |
342 | - foreach ($files as $key => $value){ |
|
343 | - if ( ($value != '.') && ($value != '..') ) { |
|
342 | + foreach ($files as $key => $value) { |
|
343 | + if (($value!='.') && ($value!='..')) { |
|
344 | 344 | $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
345 | 345 | if (is_dir($path)) { |
346 | 346 | // optionally include directories in file list |
347 | - if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path);} |
|
347 | + if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path); } |
|
348 | 348 | // optionally get file list for all subdirectories |
349 | 349 | if ($recursive) { |
350 | 350 | $subdirresults = self::getAllFilesInDirectory($path, $recursive, $basedir, $include_dirs); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | } |
359 | 359 | // merge the subarray to give the list of files then subdirectory files |
360 | - if (count($subresults) > 0) {$results = array_merge($subresults, $results);} |
|
360 | + if (count($subresults)>0) {$results = array_merge($subresults, $results); } |
|
361 | 361 | return $results; |
362 | 362 | } |
363 | 363 | |
@@ -366,18 +366,18 @@ discard block |
||
366 | 366 | * @param null $reelPath |
367 | 367 | * @return array |
368 | 368 | */ |
369 | - public static function getPathWithPhpExtension($files,$reelPath=null) |
|
369 | + public static function getPathWithPhpExtension($files, $reelPath = null) |
|
370 | 370 | { |
371 | 371 | $pathWithPhpList = []; |
372 | 372 | |
373 | - foreach ($files as $file){ |
|
373 | + foreach ($files as $file) { |
|
374 | 374 | |
375 | - if(preg_match('@(.*).php@is',$file,$pathWithPhp)){ |
|
375 | + if (preg_match('@(.*).php@is', $file, $pathWithPhp)) { |
|
376 | 376 | |
377 | - if($reelPath===null){ |
|
377 | + if ($reelPath===null) { |
|
378 | 378 | $pathWithPhpList[] = $pathWithPhp[0]; |
379 | 379 | } |
380 | - else{ |
|
380 | + else { |
|
381 | 381 | $pathWithPhpList[] = $reelPath.'/'.$pathWithPhp[0]; |
382 | 382 | } |
383 | 383 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public static function resolverClass($class) |
412 | 412 | { |
413 | - if(self::isNamespaceExists($class)){ |
|
413 | + if (self::isNamespaceExists($class)) { |
|
414 | 414 | return app()->resolve($class); |
415 | 415 | } |
416 | 416 | |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | */ |
423 | 423 | public static function getRequestPathInfo() |
424 | 424 | { |
425 | - if(is_null(BootStaticManager::getRequestPath())){ |
|
426 | - return explode("/",request()->getPathInfo()); |
|
425 | + if (is_null(BootStaticManager::getRequestPath())) { |
|
426 | + return explode("/", request()->getPathInfo()); |
|
427 | 427 | } |
428 | 428 | return BootStaticManager::getRequestPath(); |
429 | 429 | } |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | * @param null $remove |
434 | 434 | * @return array |
435 | 435 | */ |
436 | - public static function removeTrace($trace,$remove=null) |
|
436 | + public static function removeTrace($trace, $remove = null) |
|
437 | 437 | { |
438 | 438 | $list = []; |
439 | 439 | |
440 | - foreach($trace as $key=>$item){ |
|
440 | + foreach ($trace as $key=>$item) { |
|
441 | 441 | |
442 | - if(isset($item['file']) && !preg_match('@'.$remove.'@',$item['file'])){ |
|
442 | + if (isset($item['file']) && !preg_match('@'.$remove.'@', $item['file'])) { |
|
443 | 443 | $list[$key] = $item; |
444 | 444 | } |
445 | 445 | } |