| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Egulias\EmailValidator\Parser\CommentStrategy;
|
|
|
4 |
|
|
|
5 |
use Egulias\EmailValidator\EmailLexer;
|
|
|
6 |
use Egulias\EmailValidator\Result\Result;
|
|
|
7 |
use Egulias\EmailValidator\Result\ValidEmail;
|
|
|
8 |
use Egulias\EmailValidator\Warning\CFWSNearAt;
|
|
|
9 |
use Egulias\EmailValidator\Result\InvalidEmail;
|
|
|
10 |
use Egulias\EmailValidator\Result\Reason\ExpectingATEXT;
|
|
|
11 |
|
|
|
12 |
class LocalComment implements CommentStrategy
|
|
|
13 |
{
|
|
|
14 |
/**
|
|
|
15 |
* @var array
|
|
|
16 |
*/
|
|
|
17 |
private $warnings = [];
|
|
|
18 |
|
|
|
19 |
public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool
|
|
|
20 |
{
|
|
|
21 |
return !$lexer->isNextToken(EmailLexer::S_AT);
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public function endOfLoopValidations(EmailLexer $lexer) : Result
|
|
|
25 |
{
|
|
|
26 |
if (!$lexer->isNextToken(EmailLexer::S_AT)) {
|
|
|
27 |
return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), $lexer->token['value']);
|
|
|
28 |
}
|
|
|
29 |
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
|
|
30 |
return new ValidEmail();
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
public function getWarnings(): array
|
|
|
34 |
{
|
|
|
35 |
return $this->warnings;
|
|
|
36 |
}
|
|
|
37 |
}
|