| Conditions | 4 | 
| Paths | 4 | 
| Total Lines | 17 | 
| Code Lines | 10 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); | ||
| 28 | public function validate(UploadedFile $uploadedFile): void | ||
| 29 |     { | ||
| 30 |         if (!$uploadedFile->isValid()) { | ||
| 31 | throw new \InvalidArgumentException( | ||
| 32 | 'Image was not uploaded successful.' | ||
| 33 | ); | ||
| 34 | } | ||
| 35 | |||
| 36 | $bytes = $uploadedFile->getClientSize(); | ||
| 37 |         if ($bytes > $this->maxFileSize) { | ||
| 38 | $mb = $this->maxFileSize / (1024 * 1024); | ||
| 39 |             throw new \InvalidArgumentException('File is bigger then '.$mb.' MB.'); | ||
| 40 | } | ||
| 41 | |||
| 42 |         if (!in_array($uploadedFile->getMimeType(), $this->supportedMimeTypes)) { | ||
| 43 |             $types = implode(', ', $this->supportedMimeTypes); | ||
| 44 |             throw new \InvalidArgumentException('Only image types '.$types.' are supported.'); | ||
| 45 | } | ||
| 48 |