Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
ValidationStatus | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
addWarning | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
addFatal | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
getValidationErrorsData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\CommunityConfiguration\Validation; |
4 | |
5 | use StatusValue; |
6 | |
7 | class ValidationStatus extends StatusValue { |
8 | private array $validationErrors = []; |
9 | |
10 | public function addWarning( |
11 | string $property, |
12 | string $pointer, |
13 | string $messageLiteral, |
14 | array $additionalData = [] |
15 | ): void { |
16 | $this->validationErrors[] = [ |
17 | 'property' => $property, |
18 | 'pointer' => $pointer, |
19 | 'messageLiteral' => $messageLiteral, |
20 | 'additionalData' => $additionalData, |
21 | ]; |
22 | $this->warning( 'communityconfiguration-schema-validation-error', $property, $messageLiteral ); |
23 | } |
24 | |
25 | public function addFatal( |
26 | string $property, |
27 | string $pointer, |
28 | string $messageLiteral, |
29 | array $additionalData = [] |
30 | ): void { |
31 | $this->validationErrors[] = [ |
32 | 'property' => $property, |
33 | 'pointer' => $pointer, |
34 | 'messageLiteral' => $messageLiteral, |
35 | 'additionalData' => $additionalData, |
36 | ]; |
37 | $this->fatal( 'communityconfiguration-schema-validation-error', $property, $messageLiteral ); |
38 | } |
39 | |
40 | /** |
41 | * @return array{property: string, pointer: string, messageLiteral: string}[] |
42 | */ |
43 | public function getValidationErrorsData(): array { |
44 | return $this->validationErrors; |
45 | } |
46 | } |