PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Zend/Filter/Compress/CompressAbstract.php

http://github.com/michael-romer/zf-boilerplate
PHP | 89 lines | 34 code | 8 blank | 47 comment | 5 complexity | c35aae71aab5753b1520f7b88ea45b6e MD5 | raw file
Possible License(s): Unlicense, Apache-2.0
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Filter
  17. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: CompressAbstract.php 23775 2011-03-01 17:25:24Z ralph $
  20. */
  21. /**
  22. * @see Zend_Filter_Compress_CompressInterface
  23. */
  24. require_once 'Zend/Filter/Compress/CompressInterface.php';
  25. /**
  26. * Abstract compression adapter
  27. *
  28. * @category Zend
  29. * @package Zend_Filter
  30. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. abstract class Zend_Filter_Compress_CompressAbstract implements Zend_Filter_Compress_CompressInterface
  34. {
  35. /**
  36. * Class constructor
  37. *
  38. * @param array|Zend_Config $options (Optional) Options to set
  39. */
  40. public function __construct($options = null)
  41. {
  42. if ($options instanceof Zend_Config) {
  43. $options = $options->toArray();
  44. }
  45. if (is_array($options)) {
  46. $this->setOptions($options);
  47. }
  48. }
  49. /**
  50. * Returns one or all set options
  51. *
  52. * @param string $option (Optional) Option to return
  53. * @return mixed
  54. */
  55. public function getOptions($option = null)
  56. {
  57. if ($option === null) {
  58. return $this->_options;
  59. }
  60. if (!array_key_exists($option, $this->_options)) {
  61. return null;
  62. }
  63. return $this->_options[$option];
  64. }
  65. /**
  66. * Sets all or one option
  67. *
  68. * @param array $options
  69. * @return Zend_Filter_Compress_Bz2
  70. */
  71. public function setOptions(array $options)
  72. {
  73. foreach ($options as $key => $option) {
  74. $method = 'set' . $key;
  75. if (method_exists($this, $method)) {
  76. $this->$method($option);
  77. }
  78. }
  79. return $this;
  80. }
  81. }