Passed
Pull Request — master (#11)
by Steve
01:59
created

Modification   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 152
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 152
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0
wmc 15

15 Methods

Rating   Name   Duplication   Size   Complexity  
A setNext() 0 3 1
A setPrevious() 0 3 1
A getChanges() 0 3 1
A getHtmlLayoutChanges() 0 3 1
A getPrevious() 0 3 1
A getType() 0 3 1
A setChanges() 0 3 1
A setId() 0 3 1
A isFirstOfId() 0 3 1
A setFirstOfId() 0 3 1
A __construct() 0 4 1
A getNext() 0 3 1
A getId() 0 3 1
A getOutputType() 0 3 1
A setHtmlLayoutChanges() 0 3 1
1
<?php
2
/**
3
 * (c) Steve Nebes <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
declare(strict_types=1);
10
11
namespace SN\DaisyDiff\Html\Modification;
12
13
/**
14
 * Modification model.
15
 */
16
class Modification
17
{
18
    /** @var string */
19
    private $type;
20
21
    /** @var string */
22
    private $outputType;
23
24
    /** @var int */
25
    private $id = -1;
26
27
    /** @var Modification */
28
    private $prevMod;
29
30
    /** @var Modification */
31
    private $nextMod;
32
33
    /** @var bool */
34
    private $firstOfId = false;
35
36
    /** @var string */
37
    private $changes = '';
38
39
    /** @var HtmlLayoutChange[] */
40
    private $htmlLayoutChanges = [];
41
42
    /**
43
     * @param string $type
44
     * @param string $outputType
45
     */
46 79
    public function __construct(string $type, string $outputType)
47
    {
48 79
        $this->type = $type;
49 79
        $this->outputType = $outputType;
50 79
    }
51
52
    /**
53
     * @return string
54
     */
55 12
    public function getType(): string
56
    {
57 12
        return $this->type;
58
    }
59
60
    /**
61
     * Returns the type of this modification regarding output formatting (i.e. in order to specify how this modification
62
     * shall be formatted).
63
     *
64
     * In three-way diffs we format "ADDED" modifications as REMOVED, and the other way round, because the comparison is
65
     * reversed, compared to a two-way diff.
66
     *
67
     * @return string
68
     */
69 37
    public function getOutputType(): string
70
    {
71 37
        return $this->outputType;
72
    }
73
74
    /**
75
     * @return int
76
     */
77 12
    public function getId(): int
78
    {
79 12
        return $this->id;
80
    }
81
82
    /**
83
     * @param int $id
84
     */
85 25
    public function setId(int $id): void
86
    {
87 25
        $this->id = $id;
88 25
    }
89
90
    /**
91
     * @return Modification|null
92
     */
93 2
    public function getPrevious(): ?Modification
94
    {
95 2
        return $this->prevMod;
96
    }
97
98
    /**
99
     * @param Modification|null $mod
100
     */
101 10
    public function setPrevious(?Modification $mod): void
102
    {
103 10
        $this->prevMod = $mod;
104 10
    }
105
106
    /**
107
     * @return Modification|null
108
     */
109 9
    public function getNext(): ?Modification
110
    {
111 9
        return $this->nextMod;
112
    }
113
114
    /**
115
     * @param Modification|null $mod
116
     */
117 10
    public function setNext(?Modification $mod): void
118
    {
119 10
        $this->nextMod = $mod;
120 10
    }
121
122
    /**
123
     * @return string
124
     */
125 4
    public function getChanges(): string
126
    {
127 4
        return $this->changes;
128
    }
129
130
    /**
131
     * @param string $changes
132
     */
133 5
    public function setChanges(string $changes): void
134
    {
135 5
        $this->changes = $changes;
136 5
    }
137
138
    /**
139
     * @return bool
140
     */
141 13
    public function isFirstOfId(): bool
142
    {
143 13
        return $this->firstOfId;
144
    }
145
146
    /**
147
     * @param bool $value
148
     */
149 29
    public function setFirstOfId(bool $value): void
150
    {
151 29
        $this->firstOfId = $value;
152 29
    }
153
154
    /**
155
     * @return HtmlLayoutChange[]
156
     */
157 1
    public function getHtmlLayoutChanges(): array
158
    {
159 1
        return $this->htmlLayoutChanges;
160
    }
161
162
    /**
163
     * @param HtmlLayoutChange[] $htmlLayoutChanges
164
     */
165 5
    public function setHtmlLayoutChanges(array $htmlLayoutChanges): void
166
    {
167 5
        $this->htmlLayoutChanges = $htmlLayoutChanges;
168 5
    }
169
}
170