Conditions | 3 |
Paths | 4 |
Total Lines | 16 |
Lines | 3 |
Ratio | 18.75 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
16 | 4 | public function isValid($email, EmailLexer $emailLexer) |
|
17 | { |
||
18 | // use the input to check DNS if we cannot extract something similar to a domain |
||
19 | 4 | $host = $email; |
|
20 | |||
21 | // Arguable pattern to extract the domain. Not aiming to validate the domain nor the email |
||
22 | 4 | View Code Duplication | if (false !== $lastAtPos = strrpos($email, '@')) { |
|
|||
23 | 4 | $host = substr($email, $lastAtPos + 1); |
|
24 | 4 | } |
|
25 | |||
26 | 4 | if (false === strpos($host, '.')) { |
|
27 | 2 | $this->error = new LocalEmail(); |
|
28 | 2 | } |
|
29 | |||
30 | 4 | return $this->error === null; |
|
31 | } |
||
32 | |||
43 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.