Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 150
Zeile 4... Zeile 4...
4
 
4
 
5
use Egulias\EmailValidator\EmailLexer;
5
use Egulias\EmailValidator\EmailLexer;
6
use Egulias\EmailValidator\Result\InvalidEmail;
6
use Egulias\EmailValidator\Result\InvalidEmail;
7
use Egulias\EmailValidator\Validation\Exception\EmptyValidationList;
7
use Egulias\EmailValidator\Validation\Exception\EmptyValidationList;
-
 
8
use Egulias\EmailValidator\Result\MultipleErrors;
Zeile 8... Zeile 9...
8
use Egulias\EmailValidator\Result\MultipleErrors;
9
use Egulias\EmailValidator\Warning\Warning;
9
 
10
 
10
class MultipleValidationWithAnd implements EmailValidation
11
class MultipleValidationWithAnd implements EmailValidation
11
{
12
{
Zeile 25... Zeile 26...
25
     * @var EmailValidation[]
26
     * @var EmailValidation[]
26
     */
27
     */
27
    private $validations = [];
28
    private $validations = [];
Zeile 28... Zeile 29...
28
 
29
 
29
    /**
30
    /**
30
     * @var array
31
     * @var Warning[]
31
     */
32
     */
Zeile 32... Zeile 33...
32
    private $warnings = [];
33
    private $warnings = [];
33
 
34
 
Zeile 56... Zeile 57...
56
    }
57
    }
Zeile 57... Zeile 58...
57
 
58
 
58
    /**
59
    /**
59
     * {@inheritdoc}
60
     * {@inheritdoc}
60
     */
61
     */
61
    public function isValid(string $email, EmailLexer $emailLexer) : bool
62
    public function isValid(string $email, EmailLexer $emailLexer): bool
62
    {
63
    {
63
        $result = true;
64
        $result = true;
64
        foreach ($this->validations as $validation) {
65
        foreach ($this->validations as $validation) {
65
            $emailLexer->reset();
66
            $emailLexer->reset();
Zeile 76... Zeile 77...
76
        }
77
        }
Zeile 77... Zeile 78...
77
 
78
 
78
        return $result;
79
        return $result;
Zeile 79... Zeile 80...
79
    }
80
    }
80
 
81
 
81
    private function initErrorStorage() : void
82
    private function initErrorStorage(): void
82
    {
83
    {
83
        if (null === $this->error) {
84
        if (null === $this->error) {
84
            $this->error = new MultipleErrors();
85
            $this->error = new MultipleErrors();
Zeile 85... Zeile 86...
85
        }
86
        }
86
    }
87
    }
87
 
88
 
88
    private function processError(EmailValidation $validation) : void
89
    private function processError(EmailValidation $validation): void
89
    {
90
    {
90
        if (null !== $validation->getError()) {
91
        if (null !== $validation->getError()) {
91
            $this->initErrorStorage();
92
            $this->initErrorStorage();
92
            /** @psalm-suppress PossiblyNullReference */
93
            /** @psalm-suppress PossiblyNullReference */
Zeile 93... Zeile 94...
93
            $this->error->addReason($validation->getError()->reason());
94
            $this->error->addReason($validation->getError()->reason());
94
        }
95
        }
95
    }
96
    }
96
 
97
 
Zeile 97... Zeile 98...
97
    private function shouldStop(bool $result) : bool
98
    private function shouldStop(bool $result): bool
98
    {
99
    {
99
        return !$result && $this->mode === self::STOP_ON_ERROR;
100
        return !$result && $this->mode === self::STOP_ON_ERROR;
100
    }
101
    }
101
 
102
 
102
    /**
103
    /**
103
     * Returns the validation errors.
104
     * Returns the validation errors.
Zeile 104... Zeile 105...
104
     */
105
     */
105
    public function getError() : ?InvalidEmail
106
    public function getError(): ?InvalidEmail
106
    {
107
    {
107
        return $this->error;
108
        return $this->error;
108
    }
109
    }
109
 
110
 
110
    /**
111
    /**
111
     * {@inheritdoc}
112
     * @return Warning[]