3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Filter\Compress
;
13 use Zend\Stdlib\ArrayUtils
;
16 * Abstract compression adapter
18 abstract class AbstractCompressionAlgorithm
implements CompressionAlgorithmInterface
23 protected $options = array();
28 * @param null|array|Traversable $options (Optional) Options to set
30 public function __construct($options = null)
32 if ($options instanceof Traversable
) {
33 $options = ArrayUtils
::iteratorToArray($options);
36 if (is_array($options)) {
37 $this->setOptions($options);
42 * Returns one or all set options
44 * @param string $option (Optional) Option to return
47 public function getOptions($option = null)
49 if ($option === null) {
50 return $this->options
;
53 if (!array_key_exists($option, $this->options
)) {
57 return $this->options
[$option];
61 * Sets all or one option
63 * @param array $options
66 public function setOptions(array $options)
68 foreach ($options as $key => $option) {
69 $method = 'set' . $key;
70 if (method_exists($this, $method)) {
71 $this->$method($option);