| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function validate(UploadedFile $file) |
||
| 36 | { |
||
| 37 | // Check allowed types. |
||
| 38 | $fileExtension = strtolower($file->getClientOriginalExtension()); |
||
| 39 | $guessedFileExtension = strtolower($file->guessExtension()); |
||
| 40 | |||
| 41 | if (!in_array($guessedFileExtension, $this->allowedTypes)) { |
||
| 42 | $this->errors[] = 'Files of "' . $guessedFileExtension . '" type are not allowed'; |
||
| 43 | |||
| 44 | return false; |
||
| 45 | } |
||
| 46 | |||
| 47 | if (!in_array($fileExtension, $this->allowedTypes)) { |
||
| 48 | $this->errors[] = 'Files of "' . $fileExtension . '" type are not allowed'; |
||
| 49 | |||
| 50 | return false; |
||
| 51 | } |
||
| 52 | |||
| 53 | return true; |
||
| 54 | } |
||
| 55 | |||
| 79 | } |