Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
83.33% |
5 / 6 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
ParameterIsNotLexemeId | |
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 | * TODO Special. Only happens in RequestParser |
10 | * |
11 | * ParameterIsNotLexemeId |
12 | * @license GPL-2.0-or-later |
13 | */ |
14 | class ParameterIsNotLexemeId implements ApiError { |
15 | |
16 | /** |
17 | * @var string |
18 | */ |
19 | private $given; |
20 | |
21 | /** |
22 | * @param string $given |
23 | */ |
24 | public function __construct( $given ) { |
25 | $this->given = $given; |
26 | } |
27 | |
28 | /** @inheritDoc */ |
29 | public function asApiMessage( $parameterName, array $path = [] ) { |
30 | // Parameter "$1" expected to be a valid Lexeme ID (ex. "L10"), given "$2" |
31 | $message = new Message( |
32 | 'apierror-wikibaselexeme-parameter-not-lexeme-id', |
33 | [ $parameterName, json_encode( $this->given ) ] |
34 | ); |
35 | return new ApiMessage( $message, 'bad-request' ); |
36 | } |
37 | |
38 | } |