1 | <?php |
||
10 | class Changelog |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $title; |
||
16 | |||
17 | /** |
||
18 | * @var Version[] |
||
19 | */ |
||
20 | private $versions = []; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $references = []; |
||
26 | |||
27 | 1 | public function __toString() |
|
28 | { |
||
29 | 1 | $versions = join("\n", $this->versions); |
|
30 | |||
31 | 1 | krsort($this->references, SORT_NUMERIC); |
|
32 | |||
33 | 1 | $references = join("\n", array_map(function ($link, $ref) { |
|
34 | 1 | return "[#$ref]: $link"; |
|
35 | 1 | }, $this->references, array_keys($this->references))); |
|
36 | |||
37 | return <<<MD |
||
38 | 1 | # {$this->title} |
|
39 | |||
40 | |||
41 | 1 | {$versions} |
|
42 | 1 | {$references} |
|
43 | |||
44 | MD; |
||
45 | } |
||
46 | |||
47 | 2 | public function setTitle(string $title) |
|
48 | { |
||
49 | 2 | $this->title = $title; |
|
50 | 2 | } |
|
51 | |||
52 | 2 | public function addVersion(Version $version) |
|
53 | { |
||
54 | 2 | $this->versions[] = $version; |
|
55 | 2 | } |
|
56 | |||
57 | public function prependVersion(Version $version) |
||
61 | |||
62 | public function findMaster(): Version |
||
77 | |||
78 | public function findLatest(): Version |
||
88 | |||
89 | /** |
||
90 | * @param array $references |
||
91 | */ |
||
92 | 2 | public function setReferences(array $references) |
|
93 | { |
||
94 | 2 | $this->references = $references; |
|
95 | 2 | } |
|
96 | |||
97 | public function addReferences(int $ref, string $url) |
||
101 | } |
||
102 |