GithubIssueSource   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 222
Duplicated Lines 13.06 %

Coupling/Cohesion

Components 4
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 20
c 1
b 0
f 0
lcom 4
cbo 3
dl 29
loc 222
rs 10

18 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 29 29 1
A getId() 0 4 1
A getRepoId() 0 4 1
A getRepo() 0 4 1
A getNumber() 0 4 1
A getState() 0 4 1
A getTitle() 0 4 1
A getBody() 0 4 1
A getCreatedByUserId() 0 4 1
A getCreatedByUser() 0 4 1
A getAssignedToUserId() 0 8 2
A getAssignedToUser() 0 4 1
A getMilestoneId() 0 8 2
A getMilestone() 0 4 1
A getCommentCount() 0 4 1
A getGithubCreatedAt() 0 4 1
A getGithubUpdatedAt() 0 4 1
A getGithubClosedAt() 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
3
namespace DevBoardLib\GithubCore\Issue;
4
5
use DateTime;
6
use DevBoardLib\GithubCore\Issue\State\GithubIssueState;
7
use DevBoardLib\GithubCore\Milestone\GithubMilestone;
8
use DevBoardLib\GithubCore\Milestone\GithubMilestoneId;
9
use DevBoardLib\GithubCore\Repo\GithubRepo;
10
use DevBoardLib\GithubCore\Repo\GithubRepoId;
11
use DevBoardLib\GithubCore\User\GithubUser;
12
use DevBoardLib\GithubCore\User\GithubUserId;
13
14
/**
15
 * Class GithubIssueSource.
16
 */
17
class GithubIssueSource implements GithubIssue
18
{
19
    /** @var GithubIssueId */
20
    protected $id;
21
    /** @var GithubRepo */
22
    protected $repo;
23
    /** @var int */
24
    private $number;
25
    /** @var GithubIssueState */
26
    private $state;
27
    /** @var string */
28
    private $title;
29
    /** @var string */
30
    private $body;
31
    /** @var GithubUser */
32
    private $createdByUser;
33
    /** @var GithubUser */
34
    private $assignedToUser;
35
    /** @var GithubMilestone */
36
    private $milestone;
37
    /** @var int */
38
    private $commentCount;
39
    /** @var \DateTime */
40
    private $githubCreatedAt;
41
    /** @var \DateTime */
42
    private $githubUpdatedAt;
43
    /** @var \DateTime */
44
    private $githubClosedAt;
45
46
    /**
47
     * GithubIssueSource constructor.
48
     *
49
     * @param GithubIssueId    $id
50
     * @param GithubRepo       $repo
51
     * @param int              $number
52
     * @param GithubIssueState $state
53
     * @param string           $title
54
     * @param string           $body
55
     * @param GithubUser       $createdByUser
56
     * @param GithubUser       $assignedToUser
57
     * @param GithubMilestone  $milestone
58
     * @param int              $commentCount
59
     * @param DateTime         $githubCreatedAt
60
     * @param DateTime         $githubUpdatedAt
61
     * @param DateTime         $githubClosedAt
62
     *
63
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
64
     */
65 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
66
        GithubIssueId $id,
67
        GithubRepo $repo,
68
        $number,
69
        GithubIssueState $state,
70
        $title,
71
        $body,
72
        GithubUser $createdByUser,
73
        GithubUser $assignedToUser = null,
74
        GithubMilestone $milestone = null,
75
        $commentCount,
76
        DateTime $githubCreatedAt,
77
        DateTime $githubUpdatedAt,
78
        DateTime $githubClosedAt = null
79
    ) {
80
        $this->id              = $id;
81
        $this->repo            = $repo;
82
        $this->number          = $number;
83
        $this->state           = $state;
84
        $this->title           = $title;
85
        $this->body            = $body;
86
        $this->createdByUser   = $createdByUser;
87
        $this->assignedToUser  = $assignedToUser;
88
        $this->milestone       = $milestone;
89
        $this->commentCount    = $commentCount;
90
        $this->githubCreatedAt = $githubCreatedAt;
91
        $this->githubUpdatedAt = $githubUpdatedAt;
92
        $this->githubClosedAt  = $githubClosedAt;
93
    }
94
95
    /**
96
     * @return GithubIssueId
97
     */
98
    public function getId()
99
    {
100
        return $this->id;
101
    }
102
103
    /**
104
     * @return GithubRepoId
105
     */
106
    public function getRepoId()
107
    {
108
        return $this->repo->getId();
109
    }
110
111
    /**
112
     * @return GithubRepo
113
     */
114
    public function getRepo()
115
    {
116
        return $this->repo;
117
    }
118
119
    /**
120
     * @return int
121
     */
122
    public function getNumber()
123
    {
124
        return $this->number;
125
    }
126
127
    /**
128
     * @return GithubIssueState
129
     */
130
    public function getState()
131
    {
132
        return $this->state;
133
    }
134
135
    /**
136
     * @return string
137
     */
138
    public function getTitle()
139
    {
140
        return $this->title;
141
    }
142
143
    /**
144
     * @return string
145
     */
146
    public function getBody()
147
    {
148
        return $this->body;
149
    }
150
151
    /**
152
     * @return GithubUserId
153
     */
154
    public function getCreatedByUserId()
155
    {
156
        return $this->createdByUser->getGithubUserId();
157
    }
158
159
    /**
160
     * @return GithubUser
161
     */
162
    public function getCreatedByUser()
163
    {
164
        return $this->createdByUser;
165
    }
166
167
    /**
168
     * @return GithubUserId
169
     */
170
    public function getAssignedToUserId()
171
    {
172
        if (null !== $this->assignedToUser) {
173
            return $this->assignedToUser->getGithubUserId();
174
        }
175
176
        return null;
177
    }
178
179
    /**
180
     * @return GithubUser
181
     */
182
    public function getAssignedToUser()
183
    {
184
        return $this->assignedToUser;
185
    }
186
187
    /**
188
     * @return GithubMilestoneId
189
     */
190
    public function getMilestoneId()
191
    {
192
        if (null !== $this->milestone) {
193
            return $this->milestone->getId();
194
        }
195
196
        return null;
197
    }
198
199
    /**
200
     * @return GithubMilestone
201
     */
202
    public function getMilestone()
203
    {
204
        return $this->milestone;
205
    }
206
207
    /**
208
     * @return int
209
     */
210
    public function getCommentCount()
211
    {
212
        return $this->commentCount;
213
    }
214
215
    /**
216
     * @return DateTime
217
     */
218
    public function getGithubCreatedAt()
219
    {
220
        return $this->githubCreatedAt;
221
    }
222
223
    /**
224
     * @return DateTime
225
     */
226
    public function getGithubUpdatedAt()
227
    {
228
        return $this->githubUpdatedAt;
229
    }
230
231
    /**
232
     * @return DateTime
233
     */
234
    public function getGithubClosedAt()
235
    {
236
        return $this->githubClosedAt;
237
    }
238
}
239