Conditions | 4 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | 6 | public function check(): bool |
|
26 | { |
||
27 | 6 | if ($this->value === false) { |
|
28 | 1 | return true; |
|
29 | } |
||
30 | 5 | $extension = pathinfo($this->value->getClientFilename() ?? '', PATHINFO_EXTENSION); |
|
31 | |||
32 | 5 | if (is_null($this->message)) { |
|
33 | 3 | $this->message = 'Загрузка файлов с расширением .' . $extension . ' запрещена'; |
|
|
|||
34 | } |
||
35 | |||
36 | |||
37 | 5 | if (!in_array($extension, $this->expectedExtensions)) { |
|
38 | 2 | $this->element->setRuleError($this->message); |
|
39 | 2 | return false; |
|
40 | } |
||
41 | 3 | return true; |
|
42 | } |
||
44 |