1
|
|
|
<?php |
2
|
|
|
/* (c) Anton Medvedev <[email protected]> |
3
|
|
|
* |
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
5
|
|
|
* file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Deployer\Support\Changelog; |
9
|
|
|
|
10
|
|
|
class Version |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
private $version; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
private $previous; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var Item[] |
24
|
|
|
*/ |
25
|
|
|
private $added; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var Item[] |
29
|
|
|
*/ |
30
|
|
|
private $changed; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var Item[] |
34
|
|
|
*/ |
35
|
|
|
private $fixed; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var Item[] |
39
|
|
|
*/ |
40
|
|
|
private $removed; |
41
|
|
|
|
42
|
1 |
|
public function __toString() |
43
|
|
|
{ |
44
|
|
|
$f = function (Item $item) { |
45
|
1 |
|
return "- $item"; |
46
|
1 |
|
}; |
47
|
|
|
|
48
|
1 |
|
$added = ''; |
49
|
1 |
|
$changed = ''; |
50
|
1 |
|
$fixed = ''; |
51
|
1 |
|
$removed = ''; |
52
|
1 |
|
if (!empty($this->added)) { |
53
|
1 |
|
$added = implode("\n", array_map($f, $this->added)); |
54
|
1 |
|
$added = "### Added\n$added\n\n"; |
55
|
|
|
} |
56
|
1 |
|
if (!empty($this->changed)) { |
57
|
1 |
|
$changed = implode("\n", array_map($f, $this->changed)); |
58
|
1 |
|
$changed = "### Changed\n$changed\n\n"; |
59
|
|
|
} |
60
|
1 |
|
if (!empty($this->fixed)) { |
61
|
1 |
|
$fixed = implode("\n", array_map($f, $this->fixed)); |
62
|
1 |
|
$fixed = "### Fixed\n$fixed\n\n"; |
63
|
|
|
} |
64
|
1 |
|
if (!empty($this->removed)) { |
65
|
1 |
|
$removed = implode("\n", array_map($f, $this->removed)); |
66
|
1 |
|
$removed = "### Removed\n$removed\n\n"; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return <<<MD |
70
|
1 |
|
## {$this->version} |
71
|
1 |
|
[{$this->previous}...{$this->version}](https://github.com/deployphp/deployer/compare/{$this->previous}...{$this->version}) |
72
|
|
|
|
73
|
1 |
|
{$added}{$changed}{$fixed}{$removed} |
74
|
|
|
MD; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getVersion(): string |
78
|
|
|
{ |
79
|
|
|
return $this->version; |
80
|
|
|
} |
81
|
|
|
|
82
|
2 |
|
public function setVersion(string $version) |
83
|
|
|
{ |
84
|
2 |
|
$this->version = $version; |
85
|
2 |
|
} |
86
|
|
|
|
87
|
2 |
|
public function setPrevious(string $previous) |
88
|
|
|
{ |
89
|
2 |
|
$this->previous = $previous; |
90
|
2 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param Item[] $added |
94
|
|
|
*/ |
95
|
2 |
|
public function setAdded(array $added) |
96
|
|
|
{ |
97
|
2 |
|
$this->added = $added; |
98
|
2 |
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param Item[] $changed |
102
|
|
|
*/ |
103
|
2 |
|
public function setChanged(array $changed) |
104
|
|
|
{ |
105
|
2 |
|
$this->changed = $changed; |
106
|
2 |
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param Item[] $fixed |
110
|
|
|
*/ |
111
|
2 |
|
public function setFixed(array $fixed) |
112
|
|
|
{ |
113
|
2 |
|
$this->fixed = $fixed; |
114
|
2 |
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param Item[] $removed |
118
|
|
|
*/ |
119
|
2 |
|
public function setRemoved(array $removed) |
120
|
|
|
{ |
121
|
2 |
|
$this->removed = $removed; |
122
|
2 |
|
} |
123
|
|
|
|
124
|
|
|
public function addAdded(Item $added) |
125
|
|
|
{ |
126
|
|
|
$this->added[] = $added; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function addChanged(Item $changed) |
130
|
|
|
{ |
131
|
|
|
$this->changed[] = $changed; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function addFixed(Item $fixed) |
135
|
|
|
{ |
136
|
|
|
$this->fixed[] = $fixed; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function addRemoved(Item $removed) |
140
|
|
|
{ |
141
|
|
|
$this->removed[] = $removed; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|