| Total Complexity | 3 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class File extends Uploader |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Allow zip, rar, bzip, pdf, doc, docx files |
||
| 15 | * @var array allowed file types |
||
| 16 | * https://www.freeformatter.com/mime-types-list.html |
||
| 17 | */ |
||
| 18 | protected static $allowTypes = [ |
||
| 19 | "application/zip", |
||
| 20 | 'application/x-rar-compressed', |
||
| 21 | 'application/x-bzip', |
||
| 22 | "application/pdf", |
||
| 23 | "application/msword", |
||
| 24 | "application/vnd.openxmlformats-officedocument.wordprocessingml.document", |
||
| 25 | ]; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Allowed extensions to types. |
||
| 29 | * @var array |
||
| 30 | */ |
||
| 31 | protected static $extensions = [ |
||
| 32 | "zip", |
||
| 33 | "rar", |
||
| 34 | "bz", |
||
| 35 | "pdf", |
||
| 36 | "doc", |
||
| 37 | "docx" |
||
| 38 | ]; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param array $file |
||
| 42 | * @param string $name |
||
| 43 | * @return null|string |
||
| 44 | * @throws \Exception |
||
| 45 | */ |
||
| 46 | public function upload(array $file, string $name): string |
||
| 57 | } |
||
| 58 | } |