Enjoyzz /
forms
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Enjoys\Forms\Rule; |
||
| 6 | |||
| 7 | use Enjoys\Forms\Element; |
||
| 8 | use Enjoys\Forms\Interfaces\Ruleable; |
||
| 9 | use Enjoys\Forms\Traits\Request; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Description of Captcha |
||
| 13 | * |
||
| 14 | * Captcha element will automatically set the rule(s) |
||
| 15 | * $form->captcha(); |
||
| 16 | * Enjoy! |
||
| 17 | */ |
||
| 18 | class Captcha implements RuleInterface |
||
| 19 | { |
||
| 20 | use Request; |
||
| 21 | |||
| 22 | private ?string $message; |
||
| 23 | |||
| 24 | 3 | public function __construct(?string $message = null) |
|
| 25 | { |
||
| 26 | 3 | $this->message = $message; |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param Ruleable&Element $element |
||
| 31 | * @return bool |
||
| 32 | */ |
||
| 33 | 2 | public function validate(Ruleable $element): bool |
|
| 34 | { |
||
| 35 | /** @var \Enjoys\Forms\Elements\Captcha $element */ |
||
| 36 | 2 | return $element->validate(); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 37 | } |
||
| 38 | |||
| 39 | |||
| 40 | 1 | public function getMessage(): ?string |
|
| 41 | { |
||
| 42 | 1 | return $this->message; |
|
| 43 | } |
||
| 44 | } |
||
| 45 |