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