Captcha   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 1
f 0
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 4 1
A getMessage() 0 3 1
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
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