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