1 | <?php |
||
11 | class UploadedFileHelper |
||
12 | { |
||
13 | /** |
||
14 | * Check if uploaded File is valid and has a valid Mime Type. |
||
15 | * Return true is all ok, otherwise return false. |
||
16 | * @param array $arrMimeType |
||
17 | * @param UploadedFile $uploadedFile |
||
18 | * @return bool |
||
19 | */ |
||
20 | public static function isValidUploadFile(array $arrMimeType = array(), UploadedFile $uploadedFile) : bool |
||
30 | |||
31 | /** |
||
32 | * Check if uploaded File has a correct MimeType if specified. |
||
33 | * If $arrMimeType is empty array return true. |
||
34 | * @param array $arrMimeType |
||
35 | * @param UploadedFile $uploadedFile |
||
36 | * @return bool |
||
37 | */ |
||
38 | public static function hasValidMimeType(array $arrMimeType, UploadedFile $uploadedFile) : bool |
||
42 | |||
43 | /** |
||
44 | * Return the file name of uploaded file (without path and witout extension). |
||
45 | * Ex.: \public\upload\pippo.txt ritorna 'pippo' |
||
46 | * @param UploadedFile $uploadedFile |
||
47 | * @return string |
||
48 | */ |
||
49 | public static function getFilenameWithoutExtension(UploadedFile $uploadedFile) |
||
53 | |||
54 | } |
||
55 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.