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