1 | <?php |
||
8 | class MultipleValidationWithAnd implements EmailValidation |
||
9 | { |
||
10 | /** |
||
11 | * If one of validations gets failure skips all succeeding validation. |
||
12 | * This means MultipleErrors will only contain a single error which first found. |
||
13 | */ |
||
14 | const STOP_ON_ERROR = 0; |
||
15 | |||
16 | /** |
||
17 | * All of validations will be invoked even if one of them got failure. |
||
18 | * So MultipleErrors will contain all causes. |
||
19 | */ |
||
20 | const ALLOW_ALL_ERRORS = 1; |
||
21 | |||
22 | /** |
||
23 | * @var EmailValidation[] |
||
24 | */ |
||
25 | private $validations = []; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | private $warnings = []; |
||
31 | |||
32 | /** |
||
33 | * @var MultipleErrors |
||
34 | */ |
||
35 | private $error; |
||
36 | |||
37 | /** |
||
38 | * @var bool |
||
39 | */ |
||
40 | private $mode; |
||
41 | |||
42 | /** |
||
43 | * @param EmailValidation[] $validations The validations. |
||
44 | * @param int $mode The validation mode (one of the constants). |
||
45 | */ |
||
46 | 7 | public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) |
|
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | 6 | public function isValid($email, EmailLexer $emailLexer) |
|
80 | |||
81 | 6 | private function addNewError($possibleError, array $errors) |
|
89 | |||
90 | 6 | private function shouldStop($result) |
|
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | 4 | public function getError() |
|
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | 2 | public function getWarnings() |
|
110 | } |
||
111 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.