File indexing completed on 2024-12-22 05:36:41

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  * Compression adapter for Lzf
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 class Zend_Filter_Compress_Lzf implements Zend_Filter_Compress_CompressInterface
0036 {
0037     /**
0038      * Class constructor
0039      */
0040     public function __construct()
0041     {
0042         if (!extension_loaded('lzf')) {
0043             // require_once 'Zend/Filter/Exception.php';
0044             throw new Zend_Filter_Exception('This filter needs the lzf extension');
0045         }
0046     }
0047 
0048     /**
0049      * Compresses the given content
0050      *
0051      * @param  string $content
0052      * @return string
0053      */
0054     public function compress($content)
0055     {
0056         $compressed = lzf_compress($content);
0057         if (!$compressed) {
0058             // require_once 'Zend/Filter/Exception.php';
0059             throw new Zend_Filter_Exception('Error during compression');
0060         }
0061 
0062         return $compressed;
0063     }
0064 
0065     /**
0066      * Decompresses the given content
0067      *
0068      * @param  string $content
0069      * @return string
0070      */
0071     public function decompress($content)
0072     {
0073         $compressed = lzf_decompress($content);
0074         if (!$compressed) {
0075             // require_once 'Zend/Filter/Exception.php';
0076             throw new Zend_Filter_Exception('Error during compression');
0077         }
0078 
0079         return $compressed;
0080     }
0081 
0082     /**
0083      * Returns the adapter name
0084      *
0085      * @return string
0086      */
0087     public function toString()
0088     {
0089         return 'Lzf';
0090     }
0091 }