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\File
;
12 use Zend\Filter\Exception
;
13 use Zend\Filter\StringToUpper
;
15 class UpperCase
extends StringToUpper
18 * Defined by Zend\Filter\FilterInterface
20 * Does a lowercase on the content of the given file
22 * @param string|array $value Full path of file to change or $_FILES data array
23 * @return string|array The given $value
24 * @throws Exception\RuntimeException
25 * @throws Exception\InvalidArgumentException
27 public function filter($value)
29 // An uploaded file? Retrieve the 'tmp_name'
30 $isFileUpload = (is_array($value) && isset($value['tmp_name']));
33 $value = $value['tmp_name'];
36 if (!file_exists($value)) {
37 throw new Exception\
InvalidArgumentException("File '$value' not found");
40 if (!is_writable($value)) {
41 throw new Exception\
InvalidArgumentException("File '$value' is not writable");
44 $content = file_get_contents($value);
46 throw new Exception\
RuntimeException("Problem while reading file '$value'");
49 $content = parent
::filter($content);
50 $result = file_put_contents($value, $content);
53 throw new Exception\
RuntimeException("Problem while writing file '$value'");