| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | abstract class PartParser |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | protected $warnings = []; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var EmailLexer |
||
| 20 | */ |
||
| 21 | protected $lexer; |
||
| 22 | |||
| 23 | 186 | public function __construct(EmailLexer $lexer) |
|
| 24 | { |
||
| 25 | 186 | $this->lexer = $lexer; |
|
| 26 | 186 | } |
|
| 27 | |||
| 28 | abstract public function parse() : Result; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return \Egulias\EmailValidator\Warning\Warning[] |
||
| 32 | */ |
||
| 33 | 186 | public function getWarnings() |
|
| 36 | } |
||
| 37 | |||
| 38 | 114 | protected function parseFWS() : Result |
|
| 39 | { |
||
| 40 | 114 | $foldingWS = new FoldingWhiteSpace($this->lexer); |
|
| 41 | 114 | $resultFWS = $foldingWS->parse(); |
|
| 42 | 114 | $this->warnings = array_merge($this->warnings, $foldingWS->getWarnings()); |
|
| 43 | 114 | return $resultFWS; |
|
| 44 | } |
||
| 45 | |||
| 46 | 132 | protected function checkConsecutiveDots() : Result |
|
| 47 | { |
||
| 48 | 132 | if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { |
|
| 49 | 2 | return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']); |
|
| 50 | } |
||
| 51 | |||
| 52 | 132 | return new ValidEmail(); |
|
| 53 | } |
||
| 54 | |||
| 55 | 174 | protected function escaped() : bool |
|
| 62 | } |
||
| 63 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.