Issues (35)

src/Rule/Captcha.php (1 issue)

Labels
Severity
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
The method validate() does not exist on Enjoys\Forms\Interfaces\Ruleable. It seems like you code against a sub-type of Enjoys\Forms\Interfaces\Ruleable such as Enjoys\Forms\Elements\Captcha. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        return $element->/** @scrutinizer ignore-call */ validate();
Loading history...
37
    }
38
39
40 1
    public function getMessage(): ?string
41
    {
42 1
        return $this->message;
43
    }
44
}
45