Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Config\Validation; |
4 | |
5 | use InvalidArgumentException; |
6 | use StatusValue; |
7 | |
8 | interface IConfigValidator { |
9 | /** |
10 | * Validate passed config |
11 | * |
12 | * This is executed by WikiPageConfigWriter _before_ writing a config (for edits made |
13 | * via GrowthExperiments-provided interface), by ConfigHooks for manual edits and |
14 | * by WikiPageConfigLoader before returning the config (this is to ensure invalid config |
15 | * is never used). |
16 | * |
17 | * @param array $config Associative array representing config that's going to be validated |
18 | * @return StatusValue |
19 | */ |
20 | public function validate( array $config ): StatusValue; |
21 | |
22 | /** |
23 | * Validate an attempt to add a variable |
24 | * |
25 | * This is executed by WikiPageConfigWriter _before_ setVariable() runs. |
26 | * |
27 | * Implementation should throw InvalidArgumentException on any validation |
28 | * error. |
29 | * |
30 | * @param string $variable |
31 | * @param mixed $value |
32 | * @throws InvalidArgumentException In case of a validation error |
33 | */ |
34 | public function validateVariable( string $variable, $value ): void; |
35 | |
36 | /** |
37 | * If the configuration page assigned to this validator does not exist, return this |
38 | * |
39 | * Useful for ie. structured mentor list, which requires the Mentors key |
40 | * to be present. |
41 | * |
42 | * @return array |
43 | */ |
44 | public function getDefaultContent(): array; |
45 | } |