Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Unzip.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Piwik - free/libre analytics platform
  4. *
  5. * @link http://piwik.org
  6. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  7. *
  8. */
  9. namespace Piwik;
  10. use Piwik\Unzip\Gzip;
  11. use Piwik\Unzip\PclZip;
  12. use Piwik\Unzip\Tar;
  13. use Piwik\Unzip\ZipArchive;
  14. /**
  15. * Unzip wrapper around ZipArchive and PclZip
  16. *
  17. */
  18. class Unzip
  19. {
  20. /**
  21. * Factory method to create an unarchiver
  22. *
  23. * @param string $name Name of unarchiver
  24. * @param string $filename Name of .zip archive
  25. * @return \Piwik\Unzip\UncompressInterface
  26. */
  27. public static function factory($name, $filename)
  28. {
  29. switch ($name) {
  30. case 'ZipArchive':
  31. if (class_exists('ZipArchive', false))
  32. return new ZipArchive($filename);
  33. break;
  34. case 'tar.gz':
  35. return new Tar($filename, 'gz');
  36. case 'tar.bz2':
  37. return new Tar($filename, 'bz2');
  38. case 'gz':
  39. if (function_exists('gzopen'))
  40. return new Gzip($filename);
  41. break;
  42. case 'PclZip':
  43. default:
  44. return new PclZip($filename);
  45. }
  46. return new PclZip($filename);
  47. }
  48. }