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 | /** |
6 | * @license GPL-2.0-or-later |
7 | */ |
8 | class JsonFieldHasWrongType implements ApiError { |
9 | |
10 | /** |
11 | * @var string |
12 | */ |
13 | private $expectedType; |
14 | |
15 | /** |
16 | * @var string |
17 | */ |
18 | private $givenType; |
19 | |
20 | /** |
21 | * @param string $expectedType |
22 | * @param string $givenType |
23 | */ |
24 | public function __construct( $expectedType, $givenType ) { |
25 | $this->expectedType = $expectedType; |
26 | $this->givenType = $givenType; |
27 | } |
28 | |
29 | /** @inheritDoc */ |
30 | public function asApiMessage( $parameterName, array $path ) { |
31 | $message = new \Message( |
32 | 'apierror-wikibaselexeme-json-field-has-wrong-type', |
33 | [ |
34 | $parameterName, |
35 | implode( '/', $path ), |
36 | $this->expectedType, |
37 | $this->givenType, |
38 | ] |
39 | ); |
40 | return new \ApiMessage( $message, 'bad-request' ); |
41 | } |
42 | |
43 | } |