| Total Complexity | 5 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class EmailValidator |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var EmailLexer |
||
| 12 | */ |
||
| 13 | private $lexer; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var Warning\Warning[] |
||
| 17 | */ |
||
| 18 | private $warnings = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var ?InvalidEmail |
||
| 22 | */ |
||
| 23 | private $error; |
||
| 24 | |||
| 25 | 3 | public function __construct() |
|
| 26 | { |
||
| 27 | 3 | $this->lexer = new EmailLexer(); |
|
| 28 | 3 | } |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $email |
||
| 32 | * @param EmailValidation $emailValidation |
||
| 33 | * @return bool |
||
| 34 | */ |
||
| 35 | 3 | public function isValid(string $email, EmailValidation $emailValidation) |
|
| 36 | { |
||
| 37 | 3 | $isValid = $emailValidation->isValid($email, $this->lexer); |
|
| 38 | 3 | $this->warnings = $emailValidation->getWarnings(); |
|
| 39 | 3 | $this->error = $emailValidation->getError(); |
|
| 40 | |||
| 41 | 3 | return $isValid; |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return boolean |
||
| 46 | */ |
||
| 47 | 1 | public function hasWarnings() |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | 1 | public function getWarnings() |
|
| 56 | { |
||
| 57 | 1 | return $this->warnings; |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return InvalidEmail|null |
||
| 62 | */ |
||
| 63 | 1 | public function getError() |
|
| 66 | } |
||
| 67 | } |
||
| 68 |