Conditions | 5 |
Paths | 4 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5.025 |
Changes | 0 |
1 | <?php |
||
20 | 4 | public function validate($value, string $valueIdentifier = null) |
|
21 | { |
||
22 | 4 | $this->value = $value; |
|
23 | 4 | if (! is_array($value) || ! isset($value['tmp_name'])) { |
|
24 | $this->success = false; |
||
25 | 4 | } elseif (! file_exists($value['tmp_name'])) { |
|
26 | 2 | $this->success = $value['error'] === UPLOAD_ERR_NO_FILE; |
|
27 | } else { |
||
28 | 2 | $fileSize = @filesize($value['tmp_name']); |
|
29 | 2 | $limit = RuleHelper::normalizeFileSize($this->options[self::OPTION_SIZE]); |
|
30 | 2 | $this->success = $fileSize && $fileSize <= $limit; |
|
31 | } |
||
32 | |||
33 | 4 | return $this->success; |
|
34 | } |
||
35 | } |
||
36 |