Completed
Push — master ( ed861e...6484b8 )
by Eduardo Gulias
02:04
created

EmailValidator::addTLDWarnings()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 9
rs 9.2
cc 4
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Egulias\EmailValidator;
4
5
use Egulias\EmailValidator\Exception\InvalidEmail;
6
use Egulias\EmailValidator\Validation\EmailValidation;
7
8
class EmailValidator
9
{
10
    /**
11
     * @var EmailLexer
12
     */
13
    private $lexer;
14
    
15
    /**
16
     * @var array
17
     */
18
    protected $warnings;
19
20
    /**
21
     * @var InvalidEmail
22
     */
23
    protected $error;
24
    
25
    public function __construct()
26
    {
27
        $this->lexer = new EmailLexer();
28
    }
29
30
    /**
31
     * @param                 $email
32
     * @param EmailValidation $emailValidation
33
     * @return bool
34
     */
35
    public function isValid($email, EmailValidation $emailValidation)
36
    {
37
        $isValid = $emailValidation->isValid($email, $this->lexer);
38
        $this->warnings = $emailValidation->getWarnings();
39
        $this->error = $emailValidation->getError();
0 ignored issues
show
Documentation Bug introduced by
It seems like $emailValidation->getError() of type object<Egulias\EmailVali...alidation\InvalidEmail> is incompatible with the declared type object<Egulias\EmailVali...Exception\InvalidEmail> of property $error.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
        
41
        return $isValid;
42
    }
43
44
    /**
45
     * @return boolean
46
     */
47
    public function hasWarnings()
48
    {
49
        return !empty($this->warnings);
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function getWarnings()
56
    {
57
        return $this->warnings;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getError()
64
    {
65
        return $this->error;
66
    }
67
}
68