1 | <?php |
||
47 | class ValidationResult |
||
48 | { |
||
49 | /** |
||
50 | * Request was valid |
||
51 | * |
||
52 | * @var bool |
||
53 | */ |
||
54 | protected $valid = true; |
||
55 | /** |
||
56 | * Whitelisted |
||
57 | * |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $whitelisted = false; |
||
61 | /** |
||
62 | * Named whitelists |
||
63 | * |
||
64 | * @var string[] |
||
65 | */ |
||
66 | protected $whitelists = []; |
||
67 | /** |
||
68 | * Blacklisted |
||
69 | * |
||
70 | * @var bool |
||
71 | */ |
||
72 | protected $blacklisted = false; |
||
73 | /** |
||
74 | * Named blacklists |
||
75 | * |
||
76 | * @var string[] |
||
77 | */ |
||
78 | protected $blacklists = []; |
||
79 | /** |
||
80 | * Error messages |
||
81 | * |
||
82 | * @var ErrorException[] |
||
83 | */ |
||
84 | protected $errors = []; |
||
85 | |||
86 | /** |
||
87 | * Return whether the request was valid in general |
||
88 | * |
||
89 | * @return bool Valid |
||
90 | */ |
||
91 | 3 | public function isValid(): bool |
|
95 | |||
96 | /** |
||
97 | * Set whether the request was valid in general |
||
98 | * |
||
99 | * @param bool $valid Valid |
||
100 | */ |
||
101 | 1 | public function setValid(bool $valid): void |
|
105 | |||
106 | /** |
||
107 | * Return whether the request was whitelisted |
||
108 | * |
||
109 | * @return bool Whitelisted |
||
110 | */ |
||
111 | 1 | public function isWhitelisted(): bool |
|
115 | |||
116 | /** |
||
117 | * Add a named whitelist |
||
118 | * |
||
119 | * @param string $whitelist Whitelist |
||
120 | */ |
||
121 | 1 | public function addWhitelist(string $whitelist): void |
|
126 | |||
127 | /** |
||
128 | * Return all whitelists |
||
129 | * |
||
130 | * @return string[] Whitelist names |
||
131 | */ |
||
132 | public function getWhitelists(): array |
||
136 | |||
137 | /** |
||
138 | * Return whether the request was blacklisted |
||
139 | * |
||
140 | * @return bool Blacklisted |
||
141 | */ |
||
142 | public function isBlacklisted(): bool |
||
146 | |||
147 | /** |
||
148 | * Add a named blacklist |
||
149 | * |
||
150 | * @param string $blacklist Blacklist |
||
151 | */ |
||
152 | public function addBlacklist(string $blacklist): void |
||
157 | |||
158 | /** |
||
159 | * Return all blacklists |
||
160 | * |
||
161 | * @return string[] Blacklist names |
||
162 | */ |
||
163 | public function getBlacklists(): array |
||
167 | |||
168 | /** |
||
169 | * Add an error |
||
170 | * |
||
171 | * @param ErrorException $error |
||
172 | */ |
||
173 | 1 | public function addError(ErrorException $error): void |
|
177 | |||
178 | /** |
||
179 | * Return all errors |
||
180 | * |
||
181 | * @return ErrorException[] Errors |
||
182 | */ |
||
183 | 1 | public function getErrors(): array |
|
187 | |||
188 | /** |
||
189 | * Return whether this result has errors |
||
190 | * |
||
191 | * @return bool Has errors |
||
192 | */ |
||
193 | 1 | public function hasErrors(): bool |
|
197 | } |
||
198 |