diff options
author | robocoder <anthon.pang@gmail.com> | 2011-01-07 08:55:30 +0300 |
---|---|---|
committer | robocoder <anthon.pang@gmail.com> | 2011-01-07 08:55:30 +0300 |
commit | 51ed5377cde662de0df869e44d95348535cb6939 (patch) | |
tree | cb02f562cfe1e52066d20489b2d9cdba5ca10eb8 /core/Unzip.php | |
parent | b66f0e9acfcdf1d44e1ee90e5afe950e0fc3a408 (diff) |
refactoring/renaming getDefaultUnip to a factory method; unit tests use static .zip files instead of generating each time, allowing testing when ZipArchive not present
git-svn-id: http://dev.piwik.org/svn/trunk@3657 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/Unzip.php')
-rw-r--r-- | core/Unzip.php | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/core/Unzip.php b/core/Unzip.php index 81922c946a..b97ccb177a 100644 --- a/core/Unzip.php +++ b/core/Unzip.php @@ -18,16 +18,23 @@ class Piwik_Unzip { /** - * Returns an unarchiver + * Factory method to create an unarchiver * + * @param string $name Name of unarchiver * @param string $filename Name of .zip archive * @return Piwik_Unzip */ - static public function getDefaultUnzip($filename) + static public function factory($name, $filename) { - if(class_exists('ZipArchive', false)) - return new Piwik_Unzip_ZipArchive($filename); + switch($name) + { + case 'ZipArchive': + if(class_exists('ZipArchive', false)) + return new Piwik_Unzip_ZipArchive($filename); - return new Piwik_Unzip_PclZip($filename); + case 'PclZip': + default: + return new Piwik_Unzip_PclZip($filename); + } } } |