Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
TranslationUnitIssue | |
100.00% |
8 / 8 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
getSeverity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getParams | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\Translate\PageTranslation; |
5 | |
6 | use InvalidArgumentException; |
7 | use MediaWiki\Extension\Translate\Validation\ValidationIssue; |
8 | use Wikimedia\Message\MessageSpecifier; |
9 | |
10 | /** |
11 | * @author Niklas Laxström |
12 | * @license GPL-2.0-or-later |
13 | * @since 2021.05 |
14 | * @see ValidationIssue (similar, but different use case) |
15 | */ |
16 | class TranslationUnitIssue implements MessageSpecifier { |
17 | public const ERROR = 'error'; |
18 | public const WARNING = 'warning'; |
19 | /** @var string self::ERROR|self::WARNING */ |
20 | private string $severity; |
21 | private string $messageKey; |
22 | private array $messageParams; |
23 | |
24 | public function __construct( string $severity, string $messageKey, array $messageParams = [] ) { |
25 | if ( !in_array( $severity, [ self::ERROR, self::WARNING ] ) ) { |
26 | throw new InvalidArgumentException( 'Invalid value for severity: ' . $severity ); |
27 | } |
28 | $this->severity = $severity; |
29 | $this->messageKey = $messageKey; |
30 | $this->messageParams = $messageParams; |
31 | } |
32 | |
33 | public function getSeverity(): string { |
34 | return $this->severity; |
35 | } |
36 | |
37 | public function getKey(): string { |
38 | return $this->messageKey; |
39 | } |
40 | |
41 | public function getParams(): array { |
42 | return $this->messageParams; |
43 | } |
44 | } |