Total Complexity | 6 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 85.71% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class Captcha extends Element implements Ruleable, Descriptionable |
||
17 | { |
||
18 | use Traits\Description; |
||
19 | use Traits\Rules; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * @param CaptchaInterface&CaptchaBase $captcha |
||
24 | * @param string|null $message |
||
25 | * @throws ExceptionRule |
||
26 | */ |
||
27 | 19 | public function __construct(private CaptchaInterface $captcha, string $message = null) |
|
31 | } |
||
32 | |||
33 | 12 | public function prepare() |
|
34 | { |
||
35 | 12 | $this->captcha->setRequest($this->getRequest()); |
|
|
|||
36 | 12 | $this->addRule(Rules::CAPTCHA, $this->captcha->getRuleMessage()); |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 9 | public function renderHtml(): string |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | 7 | public function validate(): bool |
|
53 | { |
||
54 | 7 | return $this->captcha->validate($this); |
|
55 | } |
||
56 | |||
57 | |||
58 | public function baseHtml(): string |
||
59 | { |
||
60 | return $this->renderHtml(); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return CaptchaBase&CaptchaInterface|CaptchaInterface |
||
65 | */ |
||
66 | 1 | public function getCaptcha() |
|
69 | } |
||
70 | } |
||
71 |