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