File indexing completed on 2025-01-19 05:21:07

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Filter
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /**
0023  * @see Zend_Filter_Compress_CompressInterface
0024  */
0025 // require_once 'Zend/Filter/Compress/CompressInterface.php';
0026 
0027 /**
0028  * Abstract compression adapter
0029  *
0030  * @category   Zend
0031  * @package    Zend_Filter
0032  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0033  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0034  */
0035 abstract class Zend_Filter_Compress_CompressAbstract implements Zend_Filter_Compress_CompressInterface
0036 {
0037     /**
0038      * Class constructor
0039      *
0040      * @param array|Zend_Config $options (Optional) Options to set
0041      */
0042     public function __construct($options = null)
0043     {
0044         if ($options instanceof Zend_Config) {
0045             $options = $options->toArray();
0046         }
0047 
0048         if (is_array($options)) {
0049             $this->setOptions($options);
0050         }
0051     }
0052 
0053     /**
0054      * Returns one or all set options
0055      *
0056      * @param string $option (Optional) Option to return
0057      * @return mixed
0058      */
0059     public function getOptions($option = null)
0060     {
0061         if ($option === null) {
0062             return $this->_options;
0063         }
0064 
0065         if (!array_key_exists($option, $this->_options)) {
0066             return null;
0067         }
0068 
0069         return $this->_options[$option];
0070     }
0071 
0072     /**
0073      * Sets all or one option
0074      *
0075      * @param  array $options
0076      * @return Zend_Filter_Compress_Bz2
0077      */
0078     public function setOptions(array $options)
0079     {
0080         foreach ($options as $key => $option) {
0081             $method = 'set' . $key;
0082             if (method_exists($this, $method)) {
0083                 $this->$method($option);
0084             }
0085         }
0086 
0087         return $this;
0088     }
0089 }