Completed
Pull Request — master (#126)
by Issei
02:27
created

NoRFCWarningsValidation::getError()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Egulias\EmailValidator\Validation;
4
5
use Egulias\EmailValidator\EmailLexer;
6
use Egulias\EmailValidator\Exception\InvalidEmail;
7
use Egulias\EmailValidator\Validation\Error\RFCWarnings;
8
9
class NoRFCWarningsValidation extends RFCValidation
10
{
11
    /**
12
     * @var InvalidEmail
13
     */
14
    private $error;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 3
    public function isValid($email, EmailLexer $emailLexer)
20
    {
21 3
        if (!parent::isValid($email, $emailLexer)) {
22 1
            return false;
23
        }
24
25 2
        if (empty($this->getWarnings())) {
26 1
            return true;
27
        }
28
29 1
        $this->error = new RFCWarnings();
30
31 1
        return false;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 3
    public function getError()
38
    {
39 3
        return $this->error ?: parent::getError();
40
    }
41
}
42