Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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\Result\InvalidEmail;
9
use Egulias\EmailValidator\Result\Reason\ExpectingATEXT;
10
 
11
class DomainComment implements CommentStrategy
12
{
150 lars 13
    public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool
148 lars 14
    {
150 lars 15
        if (($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT))) { // || !$internalLexer->moveNext()) {
148 lars 16
            return false;
17
        }
18
 
19
        return true;
20
    }
21
 
150 lars 22
    public function endOfLoopValidations(EmailLexer $lexer): Result
148 lars 23
    {
24
        //test for end of string
25
        if (!$lexer->isNextToken(EmailLexer::S_DOT)) {
150 lars 26
            return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->current->value);
148 lars 27
        }
28
        //add warning
29
        //Address is valid within the message but cannot be used unmodified for the envelope
30
        return new ValidEmail();
31
    }
32
 
33
    public function getWarnings(): array
34
    {
35
        return [];
36
    }
37
}