| Total Complexity | 6 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 5 | class File |
||
| 6 | { |
||
| 7 | protected $name; |
||
| 8 | |||
| 9 | protected $size; |
||
| 10 | |||
| 11 | protected $ext; |
||
| 12 | |||
| 13 | protected $type; |
||
| 14 | |||
| 15 | protected $md5; |
||
| 16 | |||
| 17 | protected $path; |
||
| 18 | |||
| 19 | public function __construct(array $data) |
||
| 20 | { |
||
| 21 | $this->name = $data['name']; |
||
| 22 | $this->md5 = $this->generateMd5Hash($data['tmp']); |
||
| 23 | $this->size = $data['size']; |
||
| 24 | $this->ext = 'bin'; |
||
| 25 | if (preg_match("#\.#", $data['name'])) { |
||
| 26 | $ext = explode('.', $data['name']); |
||
| 27 | $this->ext = end($ext); |
||
| 28 | } |
||
| 29 | $this->type = $data['type']; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function getMd5(): string |
||
| 33 | { |
||
| 34 | return $this->md5; |
||
| 35 | } |
||
| 36 | |||
| 37 | public function setPath(string $path): void |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getData(): array |
||
| 43 | { |
||
| 44 | return [ |
||
| 45 | 'name' => $this->name, |
||
| 46 | 'md5' => $this->md5, |
||
| 47 | 'size' => $this->size, |
||
| 48 | 'ext' => $this->ext, |
||
| 49 | 'type' => $this->type, |
||
| 50 | 'path' => $this->path |
||
| 51 | ]; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function generateMd5Hash(string $file): string |
||
| 57 | } |
||
| 58 | } |
||
| 59 |