NoRFCWarningsValidation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 31
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getError() 0 3 2
A isValid() 0 13 3
1
<?php
2
3
namespace Egulias\EmailValidator\Validation;
4
5
use Egulias\EmailValidator\EmailLexer;
6
use Egulias\EmailValidator\Result\InvalidEmail;
7
use Egulias\EmailValidator\Result\Reason\RFCWarnings;
8
9
class NoRFCWarningsValidation extends RFCValidation
10
{
11
    /**
12
     * @var InvalidEmail|null
13
     */
14
    private $error;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 4
    public function isValid(string $email, EmailLexer $emailLexer) : bool
20
    {
21 4
        if (!parent::isValid($email, $emailLexer)) {
22 1
            return false;
23
        }
24
25 3
        if (empty($this->getWarnings())) {
26 2
            return true;
27
        }
28
29 1
        $this->error = new InvalidEmail(new RFCWarnings(), '');
30
31 1
        return false;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 4
    public function getError() : ?InvalidEmail
38
    {
39 4
        return $this->error ?: parent::getError();
40
    }
41
}
42