Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
71.43% |
5 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
ParameterIsNotAJsonObject | |
71.43% |
5 / 7 |
|
50.00% |
1 / 2 |
2.09 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
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 | * TODO Special. Only happens in RequestParser |
10 | * |
11 | * @license GPL-2.0-or-later |
12 | */ |
13 | class ParameterIsNotAJsonObject implements ApiError { |
14 | |
15 | /** |
16 | * @var string |
17 | */ |
18 | private $parameterName; |
19 | |
20 | /** |
21 | * @var string |
22 | */ |
23 | private $given; |
24 | |
25 | /** |
26 | * @param string $parameterName |
27 | * @param string $given |
28 | */ |
29 | public function __construct( $parameterName, $given ) { |
30 | $this->parameterName = $parameterName; |
31 | $this->given = $given; |
32 | } |
33 | |
34 | /** @inheritDoc */ |
35 | public function asApiMessage( $parameterName = null, array $path = [] ) { |
36 | $message = new Message( |
37 | 'apierror-wikibaselexeme-parameter-invalid-json-object', |
38 | [ $this->parameterName, $this->given ] |
39 | ); |
40 | return new ApiMessage( $message, 'bad-request' ); |
41 | } |
42 | |
43 | } |