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