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