Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2.024 |
Changes | 0 |
1 | <?php |
||
31 | 3 | public function validate(Ruleable $element): bool |
|
32 | { |
||
33 | 3 | $method = $this->getRequest()->getRequest()->getMethod(); |
|
34 | 3 | $requestData = match (strtolower($method)) { |
|
35 | 3 | 'get' => $this->getRequest()->getQueryData()->toArray(), |
|
36 | 'post' => $this->getRequest()->getPostData()->toArray(), |
||
37 | default => [] |
||
38 | }; |
||
39 | /** @var string $value */ |
||
40 | 3 | $value = \getValueByIndexPath($element->getName(), $requestData); |
|
|
|||
41 | 3 | if ($this->check(\trim($value)) === false) { |
|
42 | 1 | $element->setRuleError($this->message); |
|
43 | 1 | return false; |
|
44 | } |
||
45 | 2 | return true; |
|
46 | } |
||
62 |