| Conditions | 3 |
| Paths | 5 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.1825 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | 4 | public function isValid(string $email, EmailLexer $emailLexer): bool |
|
| 13 | { |
||
| 14 | 4 | $this->parser = new MessageIDParser($emailLexer); |
|
|
|
|||
| 15 | try { |
||
| 16 | 4 | $result = $this->parser->parse($email); |
|
| 17 | 4 | $this->warnings = $this->parser->getWarnings(); |
|
| 18 | 4 | if ($result->isInvalid()) { |
|
| 19 | /** @psalm-suppress PropertyTypeCoercion */ |
||
| 20 | 1 | $this->error = $result; |
|
| 21 | 4 | return false; |
|
| 22 | } |
||
| 23 | } catch (\Exception $invalid) { |
||
| 24 | $this->error = new InvalidEmail(new ExceptionFound($invalid), ''); |
||
| 25 | return false; |
||
| 26 | } |
||
| 27 | |||
| 28 | 3 | return true; |
|
| 29 | } |
||
| 30 | |||
| 41 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: