EmailValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 17
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A verdict() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Albert221\Validation\Rule;
6
7
use Albert221\Validation\Rule;
8
use Albert221\Validation\RuleValidator;
9
use Albert221\Validation\Verdict;
10
use Albert221\Validation\VerdictInterface;
11
12
class EmailValidator extends RuleValidator
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 3
    public function verdict($value, Rule $rule): VerdictInterface
18
    {
19 3
        if (is_null($value)) {
20 2
            return Verdict::passing($rule);
21
        }
22
23 2
        return Verdict::create(
24 2
            (bool) filter_var($value, FILTER_VALIDATE_EMAIL),
25 2
            $rule
26
        );
27
    }
28
}
29