1 | <?php |
||
7 | class MimeUploadValidator extends Upload_Validator |
||
|
|||
8 | { |
||
9 | /** |
||
10 | * The preg_replace() pattern to use against MIME types. Used to strip out |
||
11 | * useless characters so matching of MIME types can be fuzzy. |
||
12 | * |
||
13 | * @var string Regexp pattern |
||
14 | */ |
||
15 | protected $filterPattern = '/.*[\/\.\-\+]/i'; |
||
16 | |||
17 | public function setFilterPattern($pattern) |
||
21 | |||
22 | public function getFilterPattern() |
||
26 | |||
27 | /** |
||
28 | * Check if the temporary file has a valid MIME type for it's extension. |
||
29 | * |
||
30 | * @uses finfo php extension |
||
31 | * @return boolean|null |
||
32 | */ |
||
33 | public function isValidMime() |
||
64 | |||
65 | /** |
||
66 | * Fetches an array of valid mimetypes. |
||
67 | * |
||
68 | * @return array |
||
69 | */ |
||
70 | public function getExpectedMimeTypes($tmpFile) |
||
99 | |||
100 | /** |
||
101 | * Check two MIME types roughly match eachother. |
||
102 | * |
||
103 | * Before we check MIME types, remove known prefixes "vnd.", "x-" etc. |
||
104 | * If there is a suffix, we'll use that to compare. Examples: |
||
105 | * |
||
106 | * application/x-json = json |
||
107 | * application/json = json |
||
108 | * application/xhtml+xml = xml |
||
109 | * application/xml = xml |
||
110 | * |
||
111 | * @param string $first The first MIME type to compare to the second |
||
112 | * @param string $second The second MIME type to compare to the first |
||
113 | * @return boolean |
||
114 | */ |
||
115 | public function compareMime($first, $second) |
||
119 | |||
120 | public function validate() |
||
147 | } |
||
148 | |||
152 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.