1 | <?php |
||
48 | class ValidationResult implements ValidationResultInterface |
||
49 | { |
||
50 | /** |
||
51 | * Request was valid |
||
52 | * |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $valid = true; |
||
56 | /** |
||
57 | * Whitelisted |
||
58 | * |
||
59 | * @var bool |
||
60 | */ |
||
61 | protected $whitelisted = false; |
||
62 | /** |
||
63 | * Named whitelists |
||
64 | * |
||
65 | * @var string[] |
||
66 | */ |
||
67 | protected $whitelists = []; |
||
68 | /** |
||
69 | * Blacklisted |
||
70 | * |
||
71 | * @var bool |
||
72 | */ |
||
73 | protected $blacklisted = false; |
||
74 | /** |
||
75 | * Named blacklists |
||
76 | * |
||
77 | * @var string[] |
||
78 | */ |
||
79 | protected $blacklists = []; |
||
80 | /** |
||
81 | * Error messages |
||
82 | * |
||
83 | * @var ErrorException[] |
||
84 | */ |
||
85 | protected $errors = []; |
||
86 | /** |
||
87 | * Skipping validators |
||
88 | * |
||
89 | * @var string[] |
||
90 | */ |
||
91 | protected $skips = []; |
||
92 | /** |
||
93 | * Skipped |
||
94 | * |
||
95 | * @var bool |
||
96 | */ |
||
97 | protected $skipped = false; |
||
98 | |||
99 | /** |
||
100 | * Return whether the request was valid |
||
101 | * |
||
102 | * @return bool Valid |
||
103 | */ |
||
104 | 12 | public function isValid(): bool |
|
108 | |||
109 | /** |
||
110 | * Return whether the request was invalid |
||
111 | * |
||
112 | * @return bool Valid |
||
113 | */ |
||
114 | 10 | public function isFailed(): bool |
|
118 | |||
119 | /** |
||
120 | * Set whether the request was valid in general |
||
121 | * |
||
122 | * @param bool $valid Valid |
||
123 | */ |
||
124 | 7 | public function setValid(bool $valid): void |
|
128 | |||
129 | /** |
||
130 | * Return whether the request was whitelisted |
||
131 | * |
||
132 | * @return bool Whitelisted |
||
133 | */ |
||
134 | 3 | public function isWhitelisted(): bool |
|
138 | |||
139 | /** |
||
140 | * Add a named whitelist |
||
141 | * |
||
142 | * @param string $whitelist Whitelist |
||
143 | */ |
||
144 | 3 | public function addWhitelist(string $whitelist): void |
|
149 | |||
150 | /** |
||
151 | * Return all whitelists |
||
152 | * |
||
153 | * @return string[] Whitelist names |
||
154 | */ |
||
155 | 2 | public function getWhitelists(): array |
|
159 | |||
160 | /** |
||
161 | * Return whether the request was blacklisted |
||
162 | * |
||
163 | * @return bool Blacklisted |
||
164 | */ |
||
165 | 2 | public function isBlacklisted(): bool |
|
169 | |||
170 | /** |
||
171 | * Add a named blacklist |
||
172 | * |
||
173 | * @param string $blacklist Blacklist |
||
174 | */ |
||
175 | 2 | public function addBlacklist(string $blacklist): void |
|
180 | |||
181 | /** |
||
182 | * Return all blacklists |
||
183 | * |
||
184 | * @return string[] Blacklist names |
||
185 | */ |
||
186 | 2 | public function getBlacklists(): array |
|
190 | |||
191 | /** |
||
192 | * Add an error |
||
193 | * |
||
194 | * @param ErrorException $error |
||
195 | */ |
||
196 | 5 | public function addError(ErrorException $error): void |
|
200 | |||
201 | /** |
||
202 | * Return all errors |
||
203 | * |
||
204 | * @return ErrorException[] Errors |
||
205 | */ |
||
206 | 4 | public function getErrors(): array |
|
210 | |||
211 | /** |
||
212 | * Return whether this result has errors |
||
213 | * |
||
214 | * @return bool Has errors |
||
215 | */ |
||
216 | 6 | public function hasErrors(): bool |
|
220 | |||
221 | /** |
||
222 | * Add a skipping validator |
||
223 | * |
||
224 | * @param string $skip Skipping validator |
||
225 | */ |
||
226 | 4 | public function addSkip(string $skip): void |
|
231 | |||
232 | /** |
||
233 | * Return whether this result has skipping validators |
||
234 | * |
||
235 | * @return bool Has skipping validators |
||
236 | */ |
||
237 | 2 | public function hasSkips(): bool |
|
241 | |||
242 | /** |
||
243 | * Return whether a validator skipped this validation |
||
244 | * |
||
245 | * @return bool Validation skipped |
||
246 | */ |
||
247 | 4 | public function isSkipped(): bool |
|
251 | } |
||
252 |