Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
23.08% |
3 / 13 |
|
16.67% |
2 / 12 |
CRAP | |
0.00% |
0 / 1 |
ChangeFormDiffOp | |
23.08% |
3 / 13 |
|
16.67% |
2 / 12 |
77.54 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getFormId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRepresentationDiff | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getGrammaticalFeaturesDiff | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getStatementsDiff | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isAtomic | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
toArray | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
count | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isEmpty | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getOperations | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getArrayCopy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Wikibase\Lexeme\Domain\Diff; |
4 | |
5 | use Diff\DiffOp\Diff\Diff; |
6 | use Wikibase\DataModel\Services\Diff\EntityDiff; |
7 | use Wikibase\Lexeme\Domain\Model\FormId; |
8 | |
9 | /** |
10 | * @license GPL-2.0-or-later |
11 | * @phan-file-suppress PhanPluginNeverReturnMethod |
12 | */ |
13 | class ChangeFormDiffOp extends EntityDiff implements FormDiff { |
14 | |
15 | use Nonserializable; |
16 | |
17 | /** |
18 | * @var FormId |
19 | */ |
20 | private $formId; |
21 | /** |
22 | * @var Diff |
23 | */ |
24 | private $diffOps; |
25 | |
26 | public function __construct( FormId $formId, Diff $diffOps ) { |
27 | $this->formId = $formId; |
28 | // FIXME: This class already extends Diff. It should not require an other Diff object. |
29 | $this->diffOps = $diffOps; |
30 | } |
31 | |
32 | /** |
33 | * @return FormId |
34 | */ |
35 | public function getFormId() { |
36 | return $this->formId; |
37 | } |
38 | |
39 | /** |
40 | * @return Diff |
41 | */ |
42 | public function getRepresentationDiff() { |
43 | return $this->diffOps['representations'] ?? new Diff( [] ); |
44 | } |
45 | |
46 | /** |
47 | * @return Diff |
48 | */ |
49 | public function getGrammaticalFeaturesDiff() { |
50 | return $this->diffOps['grammaticalFeatures'] ?? new Diff( [] ); |
51 | } |
52 | |
53 | /** |
54 | * @return Diff |
55 | */ |
56 | public function getStatementsDiff() { |
57 | return $this->diffOps['claim'] ?? new Diff( [] ); |
58 | } |
59 | |
60 | public function getType(): string { |
61 | return 'diff'; |
62 | } |
63 | |
64 | public function isAtomic(): bool { |
65 | return false; |
66 | } |
67 | |
68 | public function toArray( ?callable $valueConverter = null ): array { |
69 | throw new \LogicException( "toArray() is not implemented" ); |
70 | } |
71 | |
72 | /** |
73 | * @see Diff::count |
74 | * |
75 | * @return int |
76 | */ |
77 | public function count(): int { |
78 | return $this->diffOps->count(); |
79 | } |
80 | |
81 | /** |
82 | * @see Diff::isEmpty |
83 | * |
84 | * @return bool |
85 | */ |
86 | public function isEmpty(): bool { |
87 | return $this->diffOps->isEmpty(); |
88 | } |
89 | |
90 | public function getOperations(): array { |
91 | // Due to the way this DiffOp is structured the default implementation would return nothing |
92 | throw new \LogicException( "getOperations() is not implemented" ); |
93 | } |
94 | |
95 | public function getArrayCopy(): array { |
96 | // Due to the way this DiffOp is structured the default implementation would return nothing |
97 | throw new \LogicException( "getArrayCopy() is not implemented" ); |
98 | } |
99 | |
100 | } |