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