Conditions | 3 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
41 | public function upload(array $file, string $name): string |
||
42 | { |
||
43 | $this->ext = mb_strtolower(pathinfo($file['name'])['extension']); |
||
44 | |||
45 | if (!in_array($file['type'], static::$allowTypes) || !in_array($this->ext, static::$extensions)) { |
||
46 | throw new \Exception("Not a valid file type or extension"); |
||
47 | } |
||
48 | |||
49 | $this->name($name); |
||
50 | move_uploaded_file($file['tmp_name'], "{$this->path}/{$this->name}"); |
||
51 | return "{$this->path}/{$this->name}"; |
||
52 | } |
||
53 | } |