GithubCommitStatusSource::__construct()   A
last analyzed

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