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