Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
RemoveSenseRequestParser | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
parse | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Wikibase\Lexeme\MediaWiki\Api; |
4 | |
5 | use Wikibase\Lexeme\Presentation\ChangeOp\Deserialization\SenseIdDeserializer; |
6 | use Wikibase\Lexeme\Presentation\ChangeOp\Deserialization\ValidationContext; |
7 | |
8 | /** |
9 | * @license GPL-2.0-or-later |
10 | */ |
11 | class RemoveSenseRequestParser { |
12 | |
13 | public const PARAM_SENSE_ID = 'id'; |
14 | public const PARAM_BASEREVID = 'baserevid'; |
15 | |
16 | /** |
17 | * @var SenseIdDeserializer |
18 | */ |
19 | private $senseIdDeserializer; |
20 | |
21 | public function __construct( SenseIdDeserializer $senseIdDeserializer ) { |
22 | $this->senseIdDeserializer = $senseIdDeserializer; |
23 | } |
24 | |
25 | /** |
26 | * @param array $params |
27 | * @return RemoveSenseRequest |
28 | */ |
29 | public function parse( array $params ) { |
30 | // missing $params[self::PARAM_SENSE_ID] caught by RemoveSense::getAllowedParams() |
31 | |
32 | $senseId = $this->senseIdDeserializer->deserialize( |
33 | $params[self::PARAM_SENSE_ID], |
34 | ValidationContext::create( self::PARAM_SENSE_ID ) |
35 | ); |
36 | |
37 | $baseRevId = null; |
38 | if ( isset( $params[ self::PARAM_BASEREVID ] ) ) { |
39 | $baseRevId = (int)$params[self::PARAM_BASEREVID]; |
40 | } |
41 | |
42 | return new RemoveSenseRequest( $senseId, $baseRevId ); |
43 | } |
44 | |
45 | } |