GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Changelog   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Test Coverage

Coverage 45.95%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 32
dl 0
loc 90
c 1
b 0
f 0
rs 10
ccs 17
cts 37
cp 0.4595
wmc 12

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setReferences() 0 3 1
A findLatest() 0 9 3
A setTitle() 0 3 1
A __toString() 0 16 1
A findMaster() 0 14 3
A prependVersion() 0 3 1
A addReferences() 0 3 1
A addVersion() 0 3 1
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 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
        $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)
58
    {
59
        array_unshift($this->versions, $version);
60
    }
61
62
    public function findMaster(): Version
63
    {
64
        foreach ($this->versions as $version) {
65
            if ($version->getVersion() === 'master') {
66
                return $version;
67
            }
68
        }
69
70
        $version = new Version();
71
        $version->setVersion('master');
72
        $version->setPrevious($this->findLatest()->getVersion());
73
        $this->prependVersion($version);
74
75
        return $version;
76
    }
77
78
    public function findLatest(): Version
79
    {
80
        foreach ($this->versions as $version) {
81
            if ($version->getVersion() === 'master') {
82
                continue;
83
            }
84
            return $version;
85
        }
86
        throw new \RuntimeException('There no versions.');
87
    }
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)
98
    {
99
        $this->references[$ref] = $url;
100
    }
101
}
102