Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | 6 | public function check(): bool |
|
31 | { |
||
32 | 6 | if ($this->value === false) { |
|
33 | 1 | return true; |
|
34 | } |
||
35 | |||
36 | |||
37 | 5 | $file_size = $this->value->getSize() ?? 0; |
|
38 | |||
39 | 5 | if (is_null($this->message)) { |
|
40 | 4 | $this->message = 'Размер файла (' . Binary::bytes($file_size)->format(null, " ") . ')' |
|
41 | 4 | . ' превышает допустимый размер: ' . Binary::bytes($this->thresholdSize)->format(null, " "); |
|
42 | } |
||
43 | |||
44 | 4 | if ($file_size > $this->thresholdSize) { |
|
45 | 2 | $this->element->setRuleError($this->message); |
|
46 | 2 | return false; |
|
47 | } |
||
48 | 2 | return true; |
|
49 | } |
||
51 |