Completed
Push — master ( 5da4b2...7163c3 )
by Miro
04:03 queued 01:19
created

GithubCommitStatusSource::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 19
rs 9.4285
cc 1
eloc 17
nc 1
nop 8

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\CommitStatus;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Commit\GithubCommit;
6
use DevBoardLib\GithubCore\Commit\GithubCommitId;
7
use DevBoardLib\GithubCore\CommitStatus\State\GithubCommitStatusState;
8
use DevBoardLib\GithubCore\External\ExternalService;
9
use DevBoardLib\GithubCore\External\ExternalServiceId;
10
11
/**
12
 * Class GithubCommitStatusSource.
13
 */
14
class GithubCommitStatusSource implements GithubCommitStatus
15
{
16
    /** @var GithubCommitStatusId */
17
    private $lastReceivedGithubStatusId;
18
    /** @var GithubCommitId */
19
    private $githubCommitId;
20
    /** @var ExternalServiceId */
21
    private $githubExternalServiceId;
22
    /** @var string */
23
    private $description;
24
    /** @var string */
25
    private $targetUrl;
26
    /** @var GithubCommitStatusState */
27
    private $githubState;
28
    /** @var DateTime */
29
    private $githubCreatedAt;
30
    /** @var DateTime */
31
    private $githubUpdatedAt;
32
33
    /**
34
     * GithubCommitStatusSource constructor.
35
     *
36
     * @param GithubCommitStatusId    $lastReceivedGithubStatusId
37
     * @param GithubCommitId          $githubCommitId
38
     * @param ExternalServiceId       $githubExternalServiceId
39
     * @param string                  $description
40
     * @param string                  $targetUrl
41
     * @param GithubCommitStatusState $githubState
42
     * @param DateTime                $githubCreatedAt
43
     * @param DateTime                $githubUpdatedAt
44
     */
45
    public function __construct(
46
        GithubCommitStatusId $lastReceivedGithubStatusId,
47
        GithubCommitId $githubCommitId,
48
        ExternalServiceId $githubExternalServiceId,
49
        $description,
50
        $targetUrl,
51
        GithubCommitStatusState $githubState,
52
        DateTime $githubCreatedAt,
53
        DateTime $githubUpdatedAt
54
    ) {
55
        $this->lastReceivedGithubStatusId = $lastReceivedGithubStatusId;
56
        $this->githubCommitId             = $githubCommitId;
57
        $this->githubExternalServiceId    = $githubExternalServiceId;
58
        $this->description                = $description;
59
        $this->targetUrl                  = $targetUrl;
60
        $this->githubState                = $githubState;
61
        $this->githubCreatedAt            = $githubCreatedAt;
62
        $this->githubUpdatedAt            = $githubUpdatedAt;
63
    }
64
65
    /**
66
     * @return GithubCommitStatusId
67
     */
68
    public function getLastReceivedGithubStatusId()
69
    {
70
        return $this->lastReceivedGithubStatusId;
71
    }
72
73
    /** @return GithubCommitId */
74
    public function getGithubCommitId()
75
    {
76
        return $this->githubCommitId;
77
    }
78
79
    /** @return ExternalServiceId */
80
    public function getGithubExternalServiceId()
81
    {
82
        return $this->githubExternalServiceId;
83
    }
84
85
    /** @return string */
86
    public function getDescription()
87
    {
88
        return $this->description;
89
    }
90
91
    /** @return string */
92
    public function getTargetUrl()
93
    {
94
        return $this->targetUrl;
95
    }
96
97
    /** @return GithubCommitStatusState */
98
    public function getGithubState()
99
    {
100
        return $this->githubState;
101
    }
102
103
    /** @return DateTime */
104
    public function getGithubCreatedAt()
105
    {
106
        return $this->githubCreatedAt;
107
    }
108
109
    /** @return DateTime */
110
    public function getGithubUpdatedAt()
111
    {
112
        return $this->githubUpdatedAt;
113
    }
114
}
115