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