Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ParameterIsNotFormId | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
asApiMessage | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
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 ParameterIsNotFormId 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 | * TODO formId can occur as param (formId) or in json (data). Clean generic $path solution? |
27 | * Proposal: Unification of field and path (fields being first part of path no extra treatment) |
28 | * |
29 | * @see ApiError::asApiMessage() |
30 | */ |
31 | public function asApiMessage( $parameterName, array $path ) { |
32 | $message = new Message( |
33 | 'apierror-wikibaselexeme-parameter-not-form-id', |
34 | [ $parameterName, implode( '/', $path ), json_encode( $this->given ) ] |
35 | ); |
36 | return new ApiMessage( $message, 'bad-request' ); |
37 | } |
38 | |
39 | } |