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