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_StringToUpper 0024 */ 0025 // require_once 'Zend/Filter/StringToUpper.php'; 0026 0027 /** 0028 * @category Zend 0029 * @package Zend_Filter 0030 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0031 * @license http://framework.zend.com/license/new-bsd New BSD License 0032 */ 0033 class Zend_Filter_File_UpperCase extends Zend_Filter_StringToUpper 0034 { 0035 /** 0036 * Adds options to the filter at initiation 0037 * 0038 * @param string $options 0039 */ 0040 public function __construct($options = null) 0041 { 0042 if (!empty($options)) { 0043 $this->setEncoding($options); 0044 } 0045 } 0046 0047 /** 0048 * Defined by Zend_Filter_Interface 0049 * 0050 * Does a lowercase on the content of the given file 0051 * 0052 * @param string $value Full path of file to change 0053 * @return string The given $value 0054 * @throws Zend_Filter_Exception 0055 */ 0056 public function filter($value) 0057 { 0058 if (!file_exists($value)) { 0059 // require_once 'Zend/Filter/Exception.php'; 0060 throw new Zend_Filter_Exception("File '$value' not found"); 0061 } 0062 0063 if (!is_writable($value)) { 0064 // require_once 'Zend/Filter/Exception.php'; 0065 throw new Zend_Filter_Exception("File '$value' is not writable"); 0066 } 0067 0068 $content = file_get_contents($value); 0069 if (!$content) { 0070 // require_once 'Zend/Filter/Exception.php'; 0071 throw new Zend_Filter_Exception("Problem while reading file '$value'"); 0072 } 0073 0074 $content = parent::filter($content); 0075 $result = file_put_contents($value, $content); 0076 0077 if (!$result) { 0078 // require_once 'Zend/Filter/Exception.php'; 0079 throw new Zend_Filter_Exception("Problem while writing file '$value'"); 0080 } 0081 0082 return $value; 0083 } 0084 }