Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class Captcha extends Element implements Ruleable, Descriptionable |
||
16 | { |
||
17 | use Traits\Description; |
||
18 | use Traits\Rules; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * @noinspection PhpMissingParentConstructorInspection |
||
23 | */ |
||
24 | 6 | public function __construct(private CaptchaInterface $captcha) |
|
25 | { |
||
26 | 6 | $this->setRequest(); |
|
27 | 6 | $this->setName($this->captcha->getName()); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @throws ExceptionRule |
||
32 | */ |
||
33 | 1 | public function prepare(): bool |
|
34 | { |
||
35 | 1 | $this->captcha->setRequest($this->getRequest()); |
|
36 | 1 | $this->addRule(Rules::CAPTCHA, $this->captcha->getRuleMessage()); |
|
37 | |||
38 | 1 | return false; |
|
39 | } |
||
40 | |||
41 | 1 | public function validate(): bool |
|
42 | { |
||
43 | 1 | return $this->captcha->validate($this); |
|
44 | } |
||
45 | |||
46 | |||
47 | 1 | public function baseHtml(): string |
|
48 | { |
||
49 | 1 | return $this->captcha->renderHtml($this); |
|
50 | } |
||
51 | |||
52 | 1 | public function getCaptcha(): CaptchaInterface |
|
55 | } |
||
56 | } |
||
57 |