Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Filter / File / UpperCase.php
blob69f7e84a5401d00e923e7e9c67aa89bffb0ded92
1 <?php
2 /**
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
8 */
10 namespace Zend\Filter\File;
12 use Zend\Filter\Exception;
13 use Zend\Filter\StringToUpper;
15 class UpperCase extends StringToUpper
17 /**
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']));
31 if ($isFileUpload) {
32 $uploadData = $value;
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);
45 if (!$content) {
46 throw new Exception\RuntimeException("Problem while reading file '$value'");
49 $content = parent::filter($content);
50 $result = file_put_contents($value, $content);
52 if (!$result) {
53 throw new Exception\RuntimeException("Problem while writing file '$value'");
56 if ($isFileUpload) {
57 return $uploadData;
59 return $value;