Completed
Push — master ( dd560f...9e79c2 )
by Albert
08:09
created

EmailValidator::verdict()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 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 View Code Duplication
class EmailValidator extends RuleValidator
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function verdict($value, Rule $rule): VerdictInterface
18
    {
19
        if (is_null($value)) {
20
            return Verdict::create(true, $rule);
21
        }
22
23
        return Verdict::create(
24
            (bool) filter_var($value, FILTER_VALIDATE_EMAIL),
25
            $rule
26
        );
27
    }
28
}
29