Completed
Push — master ( e447f7...0a0e4a )
by Miro
02:26
created

GithubRepoSource::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
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
3
namespace DevBoardLib\GithubCore\Repo;
4
5
use DevBoardLib\GithubCore\User\GithubUserId;
6
7
/**
8
 * Class GithubRepoSource.
9
 */
10
class GithubRepoSource implements GithubRepo, GithubRepoPermissonsInterface
11
{
12
    /** @var GithubRepoId */
13
    private $id;
14
    /** @var GithubRepoOwner */
15
    private $owner;
16
    /** @var GithubRepoName */
17
    private $name;
18
    /** @var GithubRepoFullName */
19
    private $fullName;
20
    /** @var string */
21
    private $htmlUrl;
22
    /** @var string */
23
    private $description;
24
    /** @var bool */
25
    private $fork;
26
    /** @var string */
27
    private $defaultBranchName;
28
    /** @var bool */
29
    private $private;
30
    /** @var GithubRepoGitUrl */
31
    private $gitUrl;
32
    /** @var GithubRepoSshUrl */
33
    private $sshUrl;
34
    /** @var GithubRepoPermissions */
35
    private $permissions;
36
    /** @var GithubRepoCreatedAt */
37
    private $githubCreatedAt;
38
    /** @var GithubRepoUpdatedAt */
39
    private $githubUpdatedAt;
40
    /** @var GithubRepoPushedAt */
41
    private $githubPushedAt;
42
43
    /**
44
     * GithubRepoSource constructor.
45
     *
46
     *
47
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
48
     *
49
     * @param GithubRepoId          $id
50
     * @param GithubRepoOwner       $owner
51
     * @param GithubRepoName        $name
52
     * @param GithubRepoFullName    $fullName
53
     * @param                       $htmlUrl
54
     * @param                       $description
55
     * @param bool                  $fork
56
     * @param                       $defaultBranchName
57
     * @param bool                  $private
58
     * @param GithubRepoGitUrl      $gitUrl
59
     * @param GithubRepoSshUrl      $sshUrl
60
     * @param GithubRepoPermissions $permissions
61
     * @param GithubRepoCreatedAt   $githubCreatedAt
62
     * @param GithubRepoUpdatedAt   $githubUpdatedAt
63
     * @param GithubRepoPushedAt    $githubPushedAt
64
     */
65
    public function __construct(
66
        GithubRepoId $id,
67
        GithubRepoOwner $owner,
68
        GithubRepoName $name,
69
        GithubRepoFullName $fullName,
70
        string $htmlUrl,
71
        string $description,
72
        bool $fork,
73
        string $defaultBranchName,
74
        bool $private,
75
        GithubRepoGitUrl $gitUrl,
76
        GithubRepoSshUrl $sshUrl,
77
        GithubRepoPermissions $permissions = null,
78
        GithubRepoCreatedAt $githubCreatedAt,
79
        GithubRepoUpdatedAt $githubUpdatedAt,
80
        GithubRepoPushedAt $githubPushedAt
81
    ) {
82
        $this->id                = $id;
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->defaultBranchName = $defaultBranchName;
90
        $this->private           = $private;
91
        $this->gitUrl            = $gitUrl;
92
        $this->sshUrl            = $sshUrl;
93
        $this->permissions       = $permissions;
94
        $this->githubCreatedAt   = $githubCreatedAt;
95
        $this->githubUpdatedAt   = $githubUpdatedAt;
96
        $this->githubPushedAt    = $githubPushedAt;
97
    }
98
99
    /**
100
     * @return GithubRepoId
101
     */
102
    public function getId() : GithubRepoId
103
    {
104
        return $this->id;
105
    }
106
107
    /**
108
     * @return GithubUserId
109
     */
110
    public function getOwnerUserId() : GithubUserId
111
    {
112
        return $this->owner->getGithubUserId();
113
    }
114
115
    /**
116
     * @return GithubRepoOwner
117
     */
118
    public function getOwner() : GithubRepoOwner
119
    {
120
        return $this->owner;
121
    }
122
123
    /**
124
     * @return GithubRepoName
125
     */
126
    public function getName() : GithubRepoName
127
    {
128
        return $this->name;
129
    }
130
131
    /**
132
     * @return GithubRepoFullName
133
     */
134
    public function getFullName() : GithubRepoFullName
135
    {
136
        return $this->fullName;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    public function getHtmlUrl() : string
143
    {
144
        return $this->htmlUrl;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function getDescription() : string
151
    {
152
        return $this->description;
153
    }
154
155
    /**
156
     * @return bool
157
     */
158
    public function isFork() : bool
159
    {
160
        return $this->fork;
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    public function getDefaultBranchName() : string
167
    {
168
        return $this->defaultBranchName;
169
    }
170
171
    /**
172
     * @return bool
173
     */
174
    public function isPrivate() : bool
175
    {
176
        return $this->private;
177
    }
178
179
    /**
180
     * @return GithubRepoGitUrl
181
     */
182
    public function getGitUrl() : GithubRepoGitUrl
183
    {
184
        return $this->gitUrl;
185
    }
186
187
    /**
188
     * @return GithubRepoSshUrl
189
     */
190
    public function getSshUrl() : GithubRepoSshUrl
191
    {
192
        return $this->sshUrl;
193
    }
194
195
    /**
196
     * @return bool
197
     */
198
    public function isAdmin() : bool
199
    {
200
        return $this->permissions->isAdmin();
201
    }
202
203
    /**
204
     * @return bool
205
     */
206
    public function isPushAllowed() : bool
207
    {
208
        return $this->permissions->isPushAllowed();
209
    }
210
211
    /**
212
     * @return bool
213
     */
214
    public function isReadAllowed() : bool
215
    {
216
        return $this->permissions->isReadAllowed();
217
    }
218
219
    /**
220
     * @return GithubRepoCreatedAt
221
     */
222
    public function getGithubCreatedAt() : GithubRepoCreatedAt
223
    {
224
        return $this->githubCreatedAt;
225
    }
226
227
    /**
228
     * @return GithubRepoUpdatedAt
229
     */
230
    public function getGithubUpdatedAt() : GithubRepoUpdatedAt
231
    {
232
        return $this->githubUpdatedAt;
233
    }
234
235
    /**
236
     * @return GithubRepoPushedAt
237
     */
238
    public function getGithubPushedAt() : GithubRepoPushedAt
239
    {
240
        return $this->githubPushedAt;
241
    }
242
}
243