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 |
||
29 | 7 | public function check(): bool |
|
30 | { |
||
31 | 7 | if ($this->value === false) { |
|
32 | 1 | return true; |
|
33 | } |
||
34 | 6 | $extension = pathinfo($this->value->getClientFilename() ?? '', PATHINFO_EXTENSION); |
|
35 | |||
36 | 6 | if (is_null($this->message)) { |
|
37 | 4 | $this->message = 'Загрузка файлов с расширением .' . $extension . ' запрещена'; |
|
|
|||
38 | } |
||
39 | |||
40 | |||
41 | 6 | if (!in_array(\strtolower($extension), $this->expectedExtensions, true)) { |
|
42 | 2 | $this->element->setRuleError($this->message); |
|
43 | 2 | return false; |
|
44 | } |
||
45 | 4 | return true; |
|
46 | } |
||
48 |