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

NoRFCWarningsValidation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 33
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 14 3
A getError() 0 4 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