Completed
Pull Request — master (#20)
by Miro
02:16
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 0
Metric Value
c 1
b 0
f 0
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 $id;
18
    /** @var GithubCommit */
19
    private $githubCommit;
20
    /** @var ExternalService */
21
    private $githubExternalService;
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    $id
37
     * @param GithubCommit            $githubCommit
38
     * @param ExternalService         $githubExternalService
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 $id,
47
        GithubCommit $githubCommit,
48
        ExternalService $githubExternalService,
49
        $description,
50
        $targetUrl,
51
        GithubCommitStatusState $githubState,
52
        DateTime $githubCreatedAt,
53
        DateTime $githubUpdatedAt
54
    ) {
55
        $this->id                    = $id;
56
        $this->githubCommit          = $githubCommit;
57
        $this->githubExternalService = $githubExternalService;
58
        $this->description           = $description;
59
        $this->targetUrl             = $targetUrl;
60
        $this->githubState           = $githubState;
61
        $this->githubCreatedAt       = $githubCreatedAt;
62
        $this->githubUpdatedAt       = $githubUpdatedAt;
63
    }
64
65
    /** @return GithubCommitStatusId */
66
    public function getId()
67
    {
68
        return $this->id;
69
    }
70
71
    /** @return GithubCommitId */
72
    public function getGithubCommitId()
73
    {
74
        return $this->githubCommit->getId();
75
    }
76
77
    /** @return GithubCommit */
78
    public function getGithubCommit()
79
    {
80
        return $this->githubCommit;
81
    }
82
83
    /** @return ExternalServiceId */
84
    public function getGithubExternalServiceId()
85
    {
86
        return $this->githubExternalService->getId();
87
    }
88
89
    /** @return ExternalService */
90
    public function getGithubExternalService()
91
    {
92
        return $this->githubExternalService;
93
    }
94
95
    /** @return string */
96
    public function getDescription()
97
    {
98
        return $this->description;
99
    }
100
101
    /** @return string */
102
    public function getTargetUrl()
103
    {
104
        return $this->targetUrl;
105
    }
106
107
    /** @return GithubCommitStatusState */
108
    public function getGithubState()
109
    {
110
        return $this->githubState;
111
    }
112
113
    /** @return DateTime */
114
    public function getGithubCreatedAt()
115
    {
116
        return $this->githubCreatedAt;
117
    }
118
119
    /** @return DateTime */
120
    public function getGithubUpdatedAt()
121
    {
122
        return $this->githubUpdatedAt;
123
    }
124
}
125