1 | <?php |
||
40 | class Validate |
||
41 | { |
||
42 | /** |
||
|
|||
43 | * @var array File Location |
||
44 | */ |
||
45 | |||
46 | private $_file; |
||
47 | |||
48 | /** |
||
49 | * Saves the File which must be validated |
||
50 | * |
||
51 | * @param array $file file Location |
||
52 | */ |
||
53 | public function __construct($file) |
||
64 | |||
65 | /** |
||
66 | * Check the file in dependency on a validationSet |
||
67 | * on its mime and file extension |
||
68 | * |
||
69 | * @param string $validationSet Defines the ValidationSet (e.g. image) |
||
70 | * @param bool $mime Flag for Mime Check |
||
71 | * @param bool $fileEnding Flag for File EndingCheck |
||
72 | * |
||
73 | * @throws \ErrorException |
||
74 | * |
||
75 | * @return bool |
||
76 | **/ |
||
77 | |||
78 | public function check($validationSet, $mime = true, $fileEnding = true) |
||
99 | |||
100 | /** |
||
101 | * Compares file mime with filter set |
||
102 | * |
||
103 | * @param string $validationSet Defines the ValidationSet (e.g. image) |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | |||
108 | private function _mimeCheck($validationSet) |
||
125 | |||
126 | /** |
||
127 | * Compares file extension with filter set |
||
128 | * |
||
129 | * @param string $validationSet Defines the ValidationSet (e.g. image) |
||
130 | * |
||
131 | * @return bool |
||
132 | */ |
||
133 | private function _fileEndingCheck($validationSet) |
||
149 | |||
150 | |||
151 | /** |
||
152 | * Defines several set of allowed file endings depending on filter |
||
153 | * |
||
154 | * @var array |
||
155 | */ |
||
156 | /*private static $_fileEnding = [ |
||
157 | "image" => ["jpeg", "jpg", "png", "gif"], |
||
158 | ];*/ |
||
159 | |||
160 | /** |
||
161 | * Defines several set of allowed mime types depending on filter |
||
162 | * |
||
163 | * @var array |
||
164 | */ |
||
165 | /* |
||
166 | private static $_mime = [ |
||
167 | "image" => ["image/jpeg", "image/png", "image/gif"], |
||
168 | ]; |
||
169 | */ |
||
170 | } |
||
171 |