1 | <?php |
||
9 | class MultipleValidationWithAnd implements EmailValidation |
||
10 | { |
||
11 | /** |
||
12 | * If one of validations gets failure skips all succeeding validation. |
||
13 | * This means MultipleErrors will only contain a single error which first found. |
||
14 | */ |
||
15 | const STOP_ON_ERROR = 0; |
||
16 | |||
17 | /** |
||
18 | * All of validations will be invoked even if one of them got failure. |
||
19 | * So MultipleErrors will contain all causes. |
||
20 | */ |
||
21 | const ALLOW_ALL_ERRORS = 1; |
||
22 | |||
23 | /** |
||
24 | * @var EmailValidation[] |
||
25 | */ |
||
26 | private $validations = []; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | private $warnings = []; |
||
32 | |||
33 | /** |
||
34 | * @var MultipleErrors |
||
35 | */ |
||
36 | private $error; |
||
37 | |||
38 | /** |
||
39 | * @var bool |
||
40 | */ |
||
41 | private $mode; |
||
42 | |||
43 | /** |
||
44 | * @param EmailValidation[] $validations The validations. |
||
45 | * @param int $mode The validation mode (one of the constants). |
||
46 | */ |
||
47 | 6 | public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 5 | public function isValid($email, EmailLexer $emailLexer) |
|
78 | |||
79 | 5 | private function shouldStop($result) |
|
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | 3 | public function getError() |
|
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | 2 | public function getWarnings() |
|
99 | } |
||
100 |
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.