Completed
Push — master ( 6873e8...20cc66 )
by Miro
02:52 queued 48s
created

GithubRepoSource::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 33
rs 8.8571
cc 1
eloc 31
nc 1
nop 15

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
namespace DevBoardLib\GithubCore\Repo;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Repo\GithubRepo;
6
use DevBoardLib\GithubCore\Repo\GithubRepoId;
7
use DevBoardLib\GithubCore\User\GithubUser;
8
use DevBoardLib\GithubCore\User\GithubUserId;
9
10
class GithubRepoSource implements GithubRepo
11
{
12
    /** @var GithubRepoId */
13
    private $id;
14
    /** @var GithubUser */
15
    private $ownerUser;
16
    /** @var string */
17
    private $owner;
18
    /** @var string */
19
    private $name;
20
    /** @var string */
21
    private $fullName;
22
    /** @var string */
23
    private $htmlUrl;
24
    /** @var string */
25
    private $description;
26
    /** @var int */
27
    private $fork;
28
    /** @var string */
29
    private $defaultBranch;
30
    /** @var int */
31
    private $githubPrivate;
32
    /** @var string */
33
    private $gitUrl;
34
    /** @var string */
35
    private $sshUrl;
36
    /** @var DateTime */
37
    private $githubCreatedAt;
38
    /** @var DateTime */
39
    private $githubUpdatedAt;
40
    /** @var DateTime */
41
    private $githubPushedAt;
42
43
    /**
44
     * GithubRepoSource constructor.
45
     *
46
     * @param GithubRepoId $id
47
     * @param GithubUser   $ownerUser
48
     * @param string       $owner
49
     * @param string       $name
50
     * @param string       $fullName
51
     * @param string       $htmlUrl
52
     * @param string       $description
53
     * @param int          $fork
54
     * @param string       $defaultBranch
55
     * @param int          $githubPrivate
56
     * @param string       $gitUrl
57
     * @param string       $sshUrl
58
     * @param DateTime     $githubCreatedAt
59
     * @param DateTime     $githubUpdatedAt
60
     * @param DateTime     $githubPushedAt
61
     *
62
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
63
     */
64
    public function __construct(
65
        GithubRepoId $id,
66
        GithubUser $ownerUser,
67
        $owner,
68
        $name,
69
        $fullName,
70
        $htmlUrl,
71
        $description,
72
        $fork,
73
        $defaultBranch,
74
        $githubPrivate,
75
        $gitUrl,
76
        $sshUrl,
77
        DateTime $githubCreatedAt,
78
        DateTime $githubUpdatedAt,
79
        DateTime $githubPushedAt
80
    ) {
81
        $this->id              = $id;
82
        $this->ownerUser       = $ownerUser;
83
        $this->owner           = $owner;
84
        $this->name            = $name;
85
        $this->fullName        = $fullName;
86
        $this->htmlUrl         = $htmlUrl;
87
        $this->description     = $description;
88
        $this->fork            = $fork;
89
        $this->defaultBranch   = $defaultBranch;
90
        $this->githubPrivate   = $githubPrivate;
91
        $this->gitUrl          = $gitUrl;
92
        $this->sshUrl          = $sshUrl;
93
        $this->githubCreatedAt = $githubCreatedAt;
94
        $this->githubUpdatedAt = $githubUpdatedAt;
95
        $this->githubPushedAt  = $githubPushedAt;
96
    }
97
98
    /**
99
     * @return GithubRepoId
100
     */
101
    public function getId()
102
    {
103
        return $this->id;
104
    }
105
106
    /**
107
     * @return GithubUserId
108
     */
109
    public function getOwnerUserId()
110
    {
111
        return $this->ownerUser->getGithubUserId();
112
    }
113
114
    /**
115
     * @return GithubUser
116
     */
117
    public function getOwnerUser()
118
    {
119
        return $this->ownerUser;
120
    }
121
122
    /**
123
     * @return string
124
     */
125
    public function getOwner()
126
    {
127
        return $this->owner;
128
    }
129
130
    /**
131
     * @return string
132
     */
133
    public function getName()
134
    {
135
        return $this->name;
136
    }
137
138
    /**
139
     * @return string
140
     */
141
    public function getFullName()
142
    {
143
        return $this->fullName;
144
    }
145
146
    /**
147
     * @return string
148
     */
149
    public function getHtmlUrl()
150
    {
151
        return $this->htmlUrl;
152
    }
153
154
    /**
155
     * @return string
156
     */
157
    public function getDescription()
158
    {
159
        return $this->description;
160
    }
161
162
    /**
163
     * @return int
164
     */
165
    public function getFork()
166
    {
167
        return $this->fork;
168
    }
169
170
    /**
171
     * @return string
172
     */
173
    public function getDefaultBranch()
174
    {
175
        return $this->defaultBranch;
176
    }
177
178
    /**
179
     * @return int
180
     */
181
    public function getGithubPrivate()
182
    {
183
        return $this->githubPrivate;
184
    }
185
186
    /**
187
     * @return string
188
     */
189
    public function getGitUrl()
190
    {
191
        return $this->gitUrl;
192
    }
193
194
    /**
195
     * @return string
196
     */
197
    public function getSshUrl()
198
    {
199
        return $this->sshUrl;
200
    }
201
202
    /**
203
     * @return DateTime
204
     */
205
    public function getGithubCreatedAt()
206
    {
207
        return $this->githubCreatedAt;
208
    }
209
210
    /**
211
     * @return DateTime
212
     */
213
    public function getGithubUpdatedAt()
214
    {
215
        return $this->githubUpdatedAt;
216
    }
217
218
    /**
219
     * @return DateTime
220
     */
221
    public function getGithubPushedAt()
222
    {
223
        return $this->githubPushedAt;
224
    }
225
}
226