| Conditions | 8 |
| Paths | 6 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | public function validate(UploadedFile &$file): bool |
||
| 49 | { |
||
| 50 | if ($file->filePath && is_uploaded_file($file->filePath)) { |
||
| 51 | $fileSize = filesize($file->filePath); |
||
| 52 | } else { |
||
| 53 | $fileSize = (int)$this->getServerVar('CONTENT_LENGTH'); |
||
| 54 | } |
||
| 55 | |||
| 56 | if ($this->maxFileSize && ($fileSize > $this->maxFileSize || $file->size > $this->maxFileSize)) { |
||
| 57 | $file->error = $this->getErrorMessage(); |
||
| 58 | |||
| 59 | return false; |
||
| 60 | } |
||
| 61 | if ($this->minFileSize && $fileSize < $this->minFileSize) { |
||
| 62 | $file->error = $this->getErrorMessage(); |
||
| 63 | |||
| 64 | return false; |
||
| 65 | } |
||
| 66 | |||
| 67 | return true; |
||
| 68 | } |
||
| 69 | |||
| 80 |