-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added route caching added helpers improved redirecting
- Loading branch information
Showing
12 changed files
with
145 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
if (!function_exists('humanFileSize')) { | ||
/** | ||
* Generate a human readable file size | ||
* @param $size | ||
* @param int $precision | ||
* @return string | ||
*/ | ||
function humanFileSize($size, $precision = 2): string | ||
{ | ||
for ($i = 0; ($size / 1024) > 0.9; $i++, $size /= 1024) { | ||
} | ||
return round($size, $precision) . ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'][$i]; | ||
} | ||
} | ||
|
||
if (!function_exists('removeDirectory')) { | ||
/** | ||
* Remove a directory and it's content | ||
* @param $path | ||
*/ | ||
function removeDirectory($path) | ||
{ | ||
$files = glob($path . '/*'); | ||
foreach ($files as $file) { | ||
is_dir($file) ? removeDirectory($file) : unlink($file); | ||
} | ||
rmdir($path); | ||
return; | ||
} | ||
} | ||
|
||
if (!function_exists('cleanDirectory')) { | ||
/** | ||
* Removes all directory contents | ||
* @param $path | ||
*/ | ||
function cleanDirectory($path) | ||
{ | ||
$directoryIterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); | ||
$iteratorIterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::CHILD_FIRST); | ||
foreach ($iteratorIterator as $file) { | ||
if ($file->getFilename() !== '.gitkeep') { | ||
$file->isDir() ? rmdir($file) : unlink($file); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.