From a949f90fb5c63024390ebb15dd46e2c1c1cd4c5a Mon Sep 17 00:00:00 2001 From: Hung Tran Date: Mon, 19 Jan 2015 17:46:06 -0600 Subject: [PATCH] code clean up --- classes/Foolz/Package/AssetManager.php | 6 ++--- classes/Foolz/Package/Package.php | 2 +- classes/Foolz/Package/Util.php | 37 +++++++++++--------------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/classes/Foolz/Package/AssetManager.php b/classes/Foolz/Package/AssetManager.php index 347dca8..93812e3 100644 --- a/classes/Foolz/Package/AssetManager.php +++ b/classes/Foolz/Package/AssetManager.php @@ -115,7 +115,7 @@ protected function loadAssets() mkdir($this->getPublicDir(), 0777, true); } - Util::copy_recursive($this->getPackage()->getDir().'assets', rtrim($this->getPublicDir(), '/')); + Util::copy($this->getPackage()->getDir().'assets', rtrim($this->getPublicDir(), '/')); } /** @@ -128,9 +128,9 @@ public function clearAssets() // get it just right out of the assets folder if (file_exists($this->public_dir.$this->getPackage()->getConfig('name'))) { - Util::delete_recursive($this->public_dir.$this->getPackage()->getConfig('name')); + Util::delete($this->public_dir.$this->getPackage()->getConfig('name')); } return $this; } -} \ No newline at end of file +} diff --git a/classes/Foolz/Package/Package.php b/classes/Foolz/Package/Package.php index 34e197b..bcfd509 100644 --- a/classes/Foolz/Package/Package.php +++ b/classes/Foolz/Package/Package.php @@ -336,4 +336,4 @@ public function getExtended() throw new \OutOfBoundsException('No such package available for extension.'); } } -} \ No newline at end of file +} diff --git a/classes/Foolz/Package/Util.php b/classes/Foolz/Package/Util.php index 4d24e03..ea49801 100644 --- a/classes/Foolz/Package/Util.php +++ b/classes/Foolz/Package/Util.php @@ -13,7 +13,6 @@ */ class Util { - /** * Returns the value of a deep associative array by using a dotted notation for the keys * @@ -56,8 +55,7 @@ public static function dottedConfig($config, $section, $fallback) */ public static function saveArrayToFile($path, $array) { - $content = "isDir()) { rmdir($file->getPathname()); - } - else { + } else { unlink($file->getPathname()); } } rmdir($path); - } - else { + } else { unlink($path); } } @@ -101,30 +97,27 @@ public static function delete_recursive($path) * * From: http://davidhancock.co/2012/11/useful-php-functions-for-dealing-with-the-file-system/ * - * @param string $source The path to the source file/directory - * @param string $dest The path to the destination directory + * @param string $src The path to the source file/directory + * @param string $dst The path to the destination directory * @return void */ - public static function copy_recursive($source, $dest) + public static function copy($src, $dst) { - if (is_dir($source)) { + if (is_dir($src)) { $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), + new RecursiveDirectoryIterator($src, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($iterator as $file) { if ($file->isDir()) { - mkdir($dest.DIRECTORY_SEPARATOR.$iterator->getSubPathName()); - } - else { - copy($file, $dest.DIRECTORY_SEPARATOR.$iterator->getSubPathName()); + mkdir($dst.DIRECTORY_SEPARATOR.$iterator->getSubPathName()); + } else { + copy($file, $dst.DIRECTORY_SEPARATOR.$iterator->getSubPathName()); } } - } - else { - copy($source, $dest); + } else { + copy($src, $dst); } } - -} \ No newline at end of file +}