| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 53.33% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class MessageIDValidation implements EmailValidation |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var Warning[] |
||
| 16 | */ |
||
| 17 | private $warnings = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var ?InvalidEmail |
||
| 21 | */ |
||
| 22 | private $error; |
||
| 23 | 9 | ||
| 24 | public function isValid(string $email, EmailLexer $emailLexer): bool |
||
| 25 | 9 | { |
|
| 26 | $parser = new MessageIDParser($emailLexer); |
||
| 27 | 9 | try { |
|
| 28 | 9 | $result = $parser->parse($email); |
|
| 29 | 9 | $this->warnings = $parser->getWarnings(); |
|
| 30 | if ($result->isInvalid()) { |
||
| 31 | 6 | /** @psalm-suppress PropertyTypeCoercion */ |
|
| 32 | 9 | $this->error = $result; |
|
| 33 | return false; |
||
| 34 | } |
||
| 35 | } catch (\Exception $invalid) { |
||
| 36 | $this->error = new InvalidEmail(new ExceptionFound($invalid), ''); |
||
| 37 | return false; |
||
| 38 | } |
||
| 39 | 3 | ||
| 40 | return true; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @return Warning[] |
||
| 45 | */ |
||
| 46 | public function getWarnings(): array |
||
| 49 | } |
||
| 50 | |||
| 51 | public function getError(): ?InvalidEmail |
||
| 54 | } |
||
| 55 | } |
||
| 56 |