Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 11
CRAP
0.00% covered (danger)
0.00%
0 / 1
AddFormDiff
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 11
132
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getAddedForm
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRepresentationDiff
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getGrammaticalFeaturesDiff
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
 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 Wikibase\Lexeme\Domain\Model\Form;
9
10/**
11 * @license GPL-2.0-or-later
12 */
13class AddFormDiff implements FormDiff {
14
15    use Nonserializable;
16
17    /**
18     * @var Form
19     */
20    private $form;
21
22    /**
23     * @var Diff
24     */
25    private $diffOps;
26
27    public function __construct( Form $addedForm, Diff $diffOps ) {
28        $this->form = $addedForm;
29        $this->diffOps = $diffOps;
30    }
31
32    public function getAddedForm(): Form {
33        return $this->form;
34    }
35
36    /**
37     * @return Diff
38     */
39    public function getRepresentationDiff() {
40        return $this->diffOps['representations'] ?? new Diff( [] );
41    }
42
43    /**
44     * @return Diff
45     */
46    public function getGrammaticalFeaturesDiff() {
47        return $this->diffOps['grammaticalFeatures'] ?? new Diff( [] );
48    }
49
50    /**
51     * @return Diff
52     */
53    public function getStatementsDiff() {
54        return $this->diffOps['claim'] ?? new Diff( [] );
55    }
56
57    public function getType(): string {
58        return 'diff';
59    }
60
61    public function isAtomic(): bool {
62        return false;
63    }
64
65    public function toArray( ?callable $valueConverter = null ): array {
66        throw new \LogicException( 'toArray() is not implemented' );
67    }
68
69    public function count(): int {
70        return $this->diffOps->count();
71    }
72
73    public function getOperations(): array {
74        // Due to the way this DiffOp is structured the default implementation would return nothing
75        throw new \LogicException( "getOperations() is not implemented" );
76    }
77
78    public function getArrayCopy(): array {
79        // Due to the way this DiffOp is structured the default implementation would return nothing
80        throw new \LogicException( "getArrayCopy() is not implemented" );
81    }
82
83}