Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
83.33% |
10 / 12 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
JsonFieldHasWrongType | |
83.33% |
10 / 12 |
|
50.00% |
1 / 2 |
2.02 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
asApiMessage | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Wikibase\Lexeme\MediaWiki\Api\Error; |
4 | |
5 | use MediaWiki\Api\ApiMessage; |
6 | use MediaWiki\Message\Message; |
7 | |
8 | /** |
9 | * @license GPL-2.0-or-later |
10 | */ |
11 | class JsonFieldHasWrongType implements ApiError { |
12 | |
13 | /** |
14 | * @var string |
15 | */ |
16 | private $expectedType; |
17 | |
18 | /** |
19 | * @var string |
20 | */ |
21 | private $givenType; |
22 | |
23 | /** |
24 | * @param string $expectedType |
25 | * @param string $givenType |
26 | */ |
27 | public function __construct( $expectedType, $givenType ) { |
28 | $this->expectedType = $expectedType; |
29 | $this->givenType = $givenType; |
30 | } |
31 | |
32 | /** @inheritDoc */ |
33 | public function asApiMessage( $parameterName, array $path ) { |
34 | $message = new Message( |
35 | 'apierror-wikibaselexeme-json-field-has-wrong-type', |
36 | [ |
37 | $parameterName, |
38 | implode( '/', $path ), |
39 | $this->expectedType, |
40 | $this->givenType, |
41 | ] |
42 | ); |
43 | return new ApiMessage( $message, 'bad-request' ); |
44 | } |
45 | |
46 | } |