Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
AddFormToLexemeChangeOp | |
100.00% |
10 / 10 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
validate | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
apply | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
getActions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Wikibase\Lexeme\DataAccess\ChangeOp; |
4 | |
5 | use ValueValidators\Result; |
6 | use Wikibase\DataModel\Entity\EntityDocument; |
7 | use Wikibase\Lexeme\Domain\DummyObjects\BlankForm; |
8 | use Wikibase\Lexeme\Domain\Model\Lexeme; |
9 | use Wikibase\Lib\Summary; |
10 | use Wikibase\Repo\ChangeOp\ChangeOp; |
11 | use Wikibase\Repo\ChangeOp\DummyChangeOpResult; |
12 | use Wikibase\Repo\Store\EntityPermissionChecker; |
13 | use Wikimedia\Assert\Assert; |
14 | |
15 | /** |
16 | * @license GPL-2.0-or-later |
17 | */ |
18 | class AddFormToLexemeChangeOp implements ChangeOp { |
19 | |
20 | /** |
21 | * @var Lexeme |
22 | */ |
23 | private $lexeme; |
24 | |
25 | /** |
26 | * @var ChangeOp |
27 | */ |
28 | private $changeOpFormEdit; |
29 | |
30 | public function __construct( Lexeme $lexeme, ChangeOp $changeOpFormEdit ) { |
31 | $this->lexeme = $lexeme; |
32 | $this->changeOpFormEdit = $changeOpFormEdit; |
33 | } |
34 | |
35 | public function validate( EntityDocument $form ) { |
36 | Assert::parameterType( BlankForm::class, $form, '$form' ); |
37 | |
38 | $this->changeOpFormEdit->validate( $form ); |
39 | |
40 | return Result::newSuccess(); |
41 | } |
42 | |
43 | public function apply( EntityDocument $form, ?Summary $summary = null ) { |
44 | Assert::parameterType( BlankForm::class, $form, '$form' ); |
45 | '@phan-var BlankForm $form'; |
46 | |
47 | /** @var BlankForm $form */ |
48 | $this->lexeme->addOrUpdateForm( $form ); |
49 | $this->changeOpFormEdit->apply( $form ); |
50 | |
51 | return new DummyChangeOpResult(); |
52 | } |
53 | |
54 | public function getActions() { |
55 | return [ EntityPermissionChecker::ACTION_EDIT ]; |
56 | } |
57 | |
58 | } |