Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
83.33% |
5 / 6 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
JsonFieldIsNotAnItemId | |
83.33% |
5 / 6 |
|
50.00% |
1 / 2 |
2.02 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
asApiMessage | |
100.00% |
5 / 5 |
|
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 JsonFieldIsNotAnItemId implements ApiError { |
12 | |
13 | /** |
14 | * @var string |
15 | */ |
16 | private $given; |
17 | |
18 | /** |
19 | * @param string $given |
20 | */ |
21 | public function __construct( $given ) { |
22 | $this->given = $given; |
23 | } |
24 | |
25 | /** |
26 | * @see ApiError::asApiMessage() |
27 | * |
28 | * @param string $parameterName |
29 | * @param string[] $path |
30 | */ |
31 | public function asApiMessage( $parameterName, array $path ) { |
32 | $message = new Message( |
33 | 'apierror-wikibaselexeme-json-field-not-item-id', |
34 | [ $parameterName, implode( '/', $path ), json_encode( $this->given ) ] |
35 | ); |
36 | // TODO: should be something more specific than bad-request |
37 | return new ApiMessage( $message, 'bad-request' ); |
38 | } |
39 | |
40 | } |