| Total Complexity | 4 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 92.86% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class Submit extends Rules implements RuleInterface |
||
| 12 | { |
||
| 13 | 79 | public function __construct(string $token) |
|
| 14 | { |
||
| 15 | 79 | parent::__construct(null, $token); |
|
| 16 | } |
||
| 17 | |||
| 18 | 79 | private function getToken() |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @psalm-suppress PossiblyNullReference |
||
| 25 | * @param Ruleable&Element $element |
||
| 26 | * @return bool |
||
| 27 | */ |
||
| 28 | 79 | public function validate(Ruleable $element): bool |
|
| 29 | { |
||
| 30 | |||
| 31 | 79 | $method = $this->getRequest()->getRequest()->getMethod(); |
|
| 32 | |||
| 33 | 79 | $requestData = match (strtolower($method)) { |
|
| 34 | 76 | 'get' => $this->getRequest()->getQueryData()->toArray(), |
|
| 35 | 3 | 'post' => $this->getRequest()->getPostData()->toArray(), |
|
| 36 | default => [] |
||
| 37 | }; |
||
| 38 | |||
| 39 | 79 | $value = \getValueByIndexPath($element->getName(), $requestData); |
|
|
|
|||
| 40 | |||
| 41 | 79 | return $this->check($value); |
|
| 42 | } |
||
| 43 | |||
| 44 | |||
| 45 | 79 | private function check($value): bool |
|
| 48 | } |
||
| 49 | } |
||
| 50 |