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 | /** |
6 | * TODO Special. Only happens in RequestParser |
7 | * |
8 | * ParameterIsNotLexemeId |
9 | * @license GPL-2.0-or-later |
10 | */ |
11 | class ParameterIsNotLexemeId 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 | /** @inheritDoc */ |
26 | public function asApiMessage( $parameterName, array $path = [] ) { |
27 | // Parameter "$1" expected to be a valid Lexeme ID (ex. "L10"), given "$2" |
28 | $message = new \Message( |
29 | 'apierror-wikibaselexeme-parameter-not-lexeme-id', |
30 | [ $parameterName, json_encode( $this->given ) ] |
31 | ); |
32 | return new \ApiMessage( $message, 'bad-request' ); |
33 | } |
34 | |
35 | } |