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.
Passed
Push — master ( 26c340...9e24cf )
by Anton
02:30
created

Version   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 134
Duplicated Lines 11.94 %

Coupling/Cohesion

Components 4
Dependencies 0

Test Coverage

Coverage 74.07%

Importance

Changes 0
Metric Value
dl 16
loc 134
ccs 40
cts 54
cp 0.7407
rs 10
c 0
b 0
f 0
wmc 16
lcom 4
cbo 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 16 34 5
A getVersion() 0 4 1
A setVersion() 0 4 1
A setPrevious() 0 4 1
A setAdded() 0 4 1
A setChanged() 0 4 1
A setFixed() 0 4 1
A setRemoved() 0 4 1
A addAdded() 0 4 1
A addChanged() 0 4 1
A addFixed() 0 4 1
A addRemoved() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
    public function __toString()
43
    {
44 1
        $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 View Code Duplication
        if (!empty($this->added)) {
53 1
            $added = join("\n", array_map($f, $this->added));
54 1
            $added = "### Added\n$added\n\n";
55
        }
56 1 View Code Duplication
        if (!empty($this->changed)) {
57 1
            $changed = join("\n", array_map($f, $this->changed));
58 1
            $changed = "### Changed\n$changed\n\n";
59
        }
60 1 View Code Duplication
        if (!empty($this->fixed)) {
61 1
            $fixed = join("\n", array_map($f, $this->fixed));
62 1
            $fixed = "### Fixed\n$fixed\n\n";
63
        }
64 1 View Code Duplication
        if (!empty($this->removed)) {
65 1
            $removed = join("\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