|
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
|
112 |
|
public function __construct(string $type, string $outputType) |
|
47
|
|
|
{ |
|
48
|
112 |
|
$this->type = $type; |
|
49
|
112 |
|
$this->outputType = $outputType; |
|
50
|
112 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return string |
|
54
|
|
|
*/ |
|
55
|
25 |
|
public function getType(): string |
|
56
|
|
|
{ |
|
57
|
25 |
|
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
|
70 |
|
public function getOutputType(): string |
|
70
|
|
|
{ |
|
71
|
70 |
|
return $this->outputType; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return int |
|
76
|
|
|
*/ |
|
77
|
25 |
|
public function getId(): int |
|
78
|
|
|
{ |
|
79
|
25 |
|
return $this->id; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param int $id |
|
84
|
|
|
*/ |
|
85
|
57 |
|
public function setId(int $id): void |
|
86
|
|
|
{ |
|
87
|
57 |
|
$this->id = $id; |
|
88
|
57 |
|
} |
|
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
|
28 |
|
public function setPrevious(?Modification $mod): void |
|
102
|
|
|
{ |
|
103
|
28 |
|
$this->prevMod = $mod; |
|
104
|
28 |
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return Modification|null |
|
108
|
|
|
*/ |
|
109
|
27 |
|
public function getNext(): ?Modification |
|
110
|
|
|
{ |
|
111
|
27 |
|
return $this->nextMod; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param Modification|null $mod |
|
116
|
|
|
*/ |
|
117
|
28 |
|
public function setNext(?Modification $mod): void |
|
118
|
|
|
{ |
|
119
|
28 |
|
$this->nextMod = $mod; |
|
120
|
28 |
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
20 |
|
public function getChanges(): string |
|
126
|
|
|
{ |
|
127
|
20 |
|
return $this->changes; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param string $changes |
|
132
|
|
|
*/ |
|
133
|
21 |
|
public function setChanges(string $changes): void |
|
134
|
|
|
{ |
|
135
|
21 |
|
$this->changes = $changes; |
|
136
|
21 |
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @return bool |
|
140
|
|
|
*/ |
|
141
|
38 |
|
public function isFirstOfId(): bool |
|
142
|
|
|
{ |
|
143
|
38 |
|
return $this->firstOfId; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @param bool $value |
|
148
|
|
|
*/ |
|
149
|
62 |
|
public function setFirstOfId(bool $value): void |
|
150
|
|
|
{ |
|
151
|
62 |
|
$this->firstOfId = $value; |
|
152
|
62 |
|
} |
|
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
|
21 |
|
public function setHtmlLayoutChanges(array $htmlLayoutChanges): void |
|
166
|
|
|
{ |
|
167
|
21 |
|
$this->htmlLayoutChanges = $htmlLayoutChanges; |
|
168
|
21 |
|
} |
|
169
|
|
|
} |
|
170
|
|
|
|