@@ -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,23 +173,23 @@ 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 | $forWrite = fopen($executionPath, "w"); |
191 | 191 | |
192 | - if($forWrite!==false){ |
|
192 | + if ($forWrite!==false) { |
|
193 | 193 | fwrite($forWrite, $content); |
194 | 194 | fclose($forWrite); |
195 | 195 | |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * @param $callback |
206 | 206 | * @return mixed |
207 | 207 | */ |
208 | - public static function returnCallback($data,$callback) |
|
208 | + public static function returnCallback($data, $callback) |
|
209 | 209 | { |
210 | - return call_user_func_array($callback,[$data]); |
|
210 | + return call_user_func_array($callback, [$data]); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public static function getNamespace($namespace) |
218 | 218 | { |
219 | - $rootDelete=str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'','',$namespace); |
|
219 | + $rootDelete = str_replace(root.''.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'', '', $namespace); |
|
220 | 220 | |
221 | 221 | return 'App\\'.self::generatorNamespace( |
222 | - explode(''.DIRECTORY_SEPARATOR.'',$rootDelete) |
|
222 | + explode(''.DIRECTORY_SEPARATOR.'', $rootDelete) |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public static function callbackProcess($callback) |
232 | 232 | { |
233 | - return (is_callable($callback)) ? call_user_func_array($callback,[app()]) : $callback; |
|
233 | + return (is_callable($callback)) ? call_user_func_array($callback, [app()]) : $callback; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -238,29 +238,29 @@ discard block |
||
238 | 238 | * @param $array2 |
239 | 239 | * @return bool |
240 | 240 | */ |
241 | - public static function array_diff_key_recursive ($array1, $array2) |
|
241 | + public static function array_diff_key_recursive($array1, $array2) |
|
242 | 242 | { |
243 | - if(count($array1)!==count($array2)) self::$bool[]=false; |
|
243 | + if (count($array1)!==count($array2)) self::$bool[] = false; |
|
244 | 244 | |
245 | - foreach ($array1 as $array1_key=>$array1_value){ |
|
245 | + foreach ($array1 as $array1_key=>$array1_value) { |
|
246 | 246 | |
247 | - if(!is_array($array1_value)){ |
|
248 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
247 | + if (!is_array($array1_value)) { |
|
248 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
249 | 249 | } |
250 | - else{ |
|
251 | - if(!array_key_exists($array1_key,$array2)) self::$bool[]=false; |
|
250 | + else { |
|
251 | + if (!array_key_exists($array1_key, $array2)) self::$bool[] = false; |
|
252 | 252 | |
253 | - if(!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key]=[]; |
|
253 | + if (!isset($array2[$array1_key]) OR !is_array($array2[$array1_key])) $array2[$array1_key] = []; |
|
254 | 254 | |
255 | - if(isset($array1_value[0])) $array1_value=$array1_value[0]; |
|
255 | + if (isset($array1_value[0])) $array1_value = $array1_value[0]; |
|
256 | 256 | |
257 | - if(isset($array2[$array1_key][0])) $array2[$array1_key]=$array2[$array1_key][0]; |
|
257 | + if (isset($array2[$array1_key][0])) $array2[$array1_key] = $array2[$array1_key][0]; |
|
258 | 258 | |
259 | - self::array_diff_key_recursive($array1_value,$array2[$array1_key]); |
|
259 | + self::array_diff_key_recursive($array1_value, $array2[$array1_key]); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - if(in_array(false,self::$bool)){ |
|
263 | + if (in_array(false, self::$bool)) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | return true; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public static function slashToBackSlash($data) |
274 | 274 | { |
275 | - return str_replace("/","\\",$data); |
|
275 | + return str_replace("/", "\\", $data); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | * @param null $key |
281 | 281 | * @return null |
282 | 282 | */ |
283 | - public static function trace($debug=0,$key=null) |
|
283 | + public static function trace($debug = 0, $key = null) |
|
284 | 284 | { |
285 | - $trace=debug_backtrace(); |
|
285 | + $trace = debug_backtrace(); |
|
286 | 286 | |
287 | - if($key===null){ |
|
287 | + if ($key===null) { |
|
288 | 288 | return $trace[$debug] ?? null; |
289 | 289 | } |
290 | 290 | return $trace[$debug][$key] ?? null; |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | public static function chmod_r($dir, $dirPermissions, $filePermissions) |
300 | 300 | { |
301 | 301 | $dp = opendir($dir); |
302 | - while($file = readdir($dp)) { |
|
303 | - if (($file == ".") || ($file == "..")) |
|
302 | + while ($file = readdir($dp)) { |
|
303 | + if (($file==".") || ($file=="..")) |
|
304 | 304 | continue; |
305 | 305 | |
306 | 306 | $fullPath = $dir."/".$file; |
307 | 307 | |
308 | - if(is_dir($fullPath)) { |
|
308 | + if (is_dir($fullPath)) { |
|
309 | 309 | chmod($fullPath, $dirPermissions); |
310 | 310 | self::chmod_r($fullPath, $dirPermissions, $filePermissions); |
311 | 311 | } else { |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public static function getServiceConf() |
323 | 323 | { |
324 | - if(property_exists(core(),'serviceConf') && defined('methodName')){ |
|
324 | + if (property_exists(core(), 'serviceConf') && defined('methodName')) { |
|
325 | 325 | return core()->serviceConf; |
326 | 326 | } |
327 | 327 | return []; |
@@ -337,17 +337,17 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public static function getAllFilesInDirectory($dir, $recursive = true, $basedir = '', $include_dirs = false) |
339 | 339 | { |
340 | - if ($dir == '') {return array();} else {$results = array(); $subresults = array();} |
|
341 | - if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent |
|
342 | - if ($basedir == '') {$basedir = realpath($dir).DIRECTORY_SEPARATOR;} |
|
340 | + if ($dir=='') {return array(); } else {$results = array(); $subresults = array(); } |
|
341 | + if (!is_dir($dir)) {$dir = dirname($dir); } // so a files path can be sent |
|
342 | + if ($basedir=='') {$basedir = realpath($dir).DIRECTORY_SEPARATOR; } |
|
343 | 343 | |
344 | 344 | $files = scandir($dir); |
345 | - foreach ($files as $key => $value){ |
|
346 | - if ( ($value != '.') && ($value != '..') ) { |
|
345 | + foreach ($files as $key => $value) { |
|
346 | + if (($value!='.') && ($value!='..')) { |
|
347 | 347 | $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
348 | 348 | if (is_dir($path)) { |
349 | 349 | // optionally include directories in file list |
350 | - if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path);} |
|
350 | + if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path); } |
|
351 | 351 | // optionally get file list for all subdirectories |
352 | 352 | if ($recursive) { |
353 | 353 | $subdirresults = self::getAllFilesInDirectory($path, $recursive, $basedir, $include_dirs); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | } |
361 | 361 | } |
362 | 362 | // merge the subarray to give the list of files then subdirectory files |
363 | - if (count($subresults) > 0) {$results = array_merge($subresults, $results);} |
|
363 | + if (count($subresults)>0) {$results = array_merge($subresults, $results); } |
|
364 | 364 | return $results; |
365 | 365 | } |
366 | 366 | |
@@ -369,18 +369,18 @@ discard block |
||
369 | 369 | * @param null $reelPath |
370 | 370 | * @return array |
371 | 371 | */ |
372 | - public static function getPathWithPhpExtension($files,$reelPath=null) |
|
372 | + public static function getPathWithPhpExtension($files, $reelPath = null) |
|
373 | 373 | { |
374 | 374 | $pathWithPhpList = []; |
375 | 375 | |
376 | - foreach ($files as $file){ |
|
376 | + foreach ($files as $file) { |
|
377 | 377 | |
378 | - if(preg_match('@(.*).php@is',$file,$pathWithPhp)){ |
|
378 | + if (preg_match('@(.*).php@is', $file, $pathWithPhp)) { |
|
379 | 379 | |
380 | - if($reelPath===null){ |
|
380 | + if ($reelPath===null) { |
|
381 | 381 | $pathWithPhpList[] = $pathWithPhp[0]; |
382 | 382 | } |
383 | - else{ |
|
383 | + else { |
|
384 | 384 | $pathWithPhpList[] = $reelPath.'/'.$pathWithPhp[0]; |
385 | 385 | } |
386 | 386 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | */ |
414 | 414 | public static function resolverClass($class) |
415 | 415 | { |
416 | - if(self::isNamespaceExists($class)){ |
|
416 | + if (self::isNamespaceExists($class)) { |
|
417 | 417 | return app()->resolve($class); |
418 | 418 | } |
419 | 419 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public static function getRequestPathInfo() |
427 | 427 | { |
428 | - if(is_null(BootStaticManager::getRequestPath())){ |
|
429 | - return explode("/",request()->getPathInfo()); |
|
428 | + if (is_null(BootStaticManager::getRequestPath())) { |
|
429 | + return explode("/", request()->getPathInfo()); |
|
430 | 430 | } |
431 | 431 | return BootStaticManager::getRequestPath(); |
432 | 432 | } |
@@ -436,13 +436,13 @@ discard block |
||
436 | 436 | * @param null $remove |
437 | 437 | * @return array |
438 | 438 | */ |
439 | - public static function removeTrace($trace,$remove=null) |
|
439 | + public static function removeTrace($trace, $remove = null) |
|
440 | 440 | { |
441 | 441 | $list = []; |
442 | 442 | |
443 | - foreach($trace as $key=>$item){ |
|
443 | + foreach ($trace as $key=>$item) { |
|
444 | 444 | |
445 | - if(isset($item['file']) && !preg_match('@'.$remove.'@',$item['file'])){ |
|
445 | + if (isset($item['file']) && !preg_match('@'.$remove.'@', $item['file'])) { |
|
446 | 446 | $list[$key] = $item; |
447 | 447 | } |
448 | 448 | } |