| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function upload(array $file, string $name): string |
||
| 33 | { |
||
| 34 | if (!in_array($file['type'], static::$allowTypes)) { |
||
| 35 | throw new \Exception("{$file['type']} - Not a valid file type"); |
||
| 36 | } else { |
||
| 37 | $this->ext = mb_strtolower(pathinfo($file['name'])['extension']); |
||
| 38 | $this->name($name); |
||
| 39 | } |
||
| 40 | |||
| 41 | move_uploaded_file($file['tmp_name'], "{$this->path}/{$this->name}"); |
||
| 42 | return "{$this->path}/{$this->name}"; |
||
| 43 | } |
||
| 44 | } |