Completed
Push — master ( 12f683...a4b1f6 )
by Miro
02:18
created

GithubRepoSourceSpec::let()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 35
rs 8.8571
cc 1
eloc 32
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 spec\DevBoardLib\GithubObjectApiFacade\Repo\Repo;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Repo\GithubRepoId;
6
use DevBoardLib\GithubCore\User\GithubUser;
7
use DevBoardLib\GithubCore\User\GithubUserId;
8
use PhpSpec\ObjectBehavior;
9
use Prophecy\Argument;
10
11
class GithubRepoSourceSpec extends ObjectBehavior
12
{
13
    public function it_is_initializable()
14
    {
15
        $this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\Repo\GithubRepoSource');
16
        $this->shouldHaveType('DevBoardLib\GithubCore\Repo\GithubRepo');
17
    }
18
19
    public function let(
20
        GithubRepoId $id,
21
        GithubUser $ownerUser,
22
        $owner,
23
        $name,
24
        $fullName,
25
        $htmlUrl,
26
        $description,
27
        $fork,
28
        $defaultBranch,
29
        $githubPrivate,
30
        $gitUrl,
31
        $sshUrl,
32
        DateTime $githubCreatedAt,
33
        DateTime $githubUpdatedAt,
34
        DateTime $githubPushedAt
35
    ) {
36
        $this->beConstructedWith(
37
            $id,
38
            $ownerUser,
39
            $owner,
40
            $name,
41
            $fullName,
42
            $htmlUrl,
43
            $description,
44
            $fork,
45
            $defaultBranch,
46
            $githubPrivate,
47
            $gitUrl,
48
            $sshUrl,
49
            $githubCreatedAt,
50
            $githubUpdatedAt,
51
            $githubPushedAt
52
        );
53
    }
54
55
    public function it_exposes_all_constructor_params_via_getters(
56
        $id,
57
        $ownerUser,
58
        $owner,
59
        $name,
60
        $fullName,
61
        $htmlUrl,
62
        $description,
63
        $fork,
64
        $defaultBranch,
65
        $githubPrivate,
66
        $gitUrl,
67
        $sshUrl,
68
        $githubCreatedAt,
69
        $githubUpdatedAt,
70
        $githubPushedAt,
71
        GithubUserId $ownerUserId
72
    ) {
73
        $ownerUser->getGithubUserId()->willReturn($ownerUserId);
74
75
        $this->getId()->shouldReturn($id);
76
        $this->getOwnerUserId()->shouldReturn($ownerUserId);
77
        $this->getOwnerUser()->shouldReturn($ownerUser);
78
        $this->getOwner()->shouldReturn($owner);
79
        $this->getName()->shouldReturn($name);
80
        $this->getFullName()->shouldReturn($fullName);
81
        $this->getHtmlUrl()->shouldReturn($htmlUrl);
82
        $this->getDescription()->shouldReturn($description);
83
        $this->getFork()->shouldReturn($fork);
84
        $this->getDefaultBranch()->shouldReturn($defaultBranch);
85
        $this->getGithubPrivate()->shouldReturn($githubPrivate);
86
        $this->getGitUrl()->shouldReturn($gitUrl);
87
        $this->getSshUrl()->shouldReturn($sshUrl);
88
        $this->getGithubCreatedAt()->shouldReturn($githubCreatedAt);
89
        $this->getGithubUpdatedAt()->shouldReturn($githubUpdatedAt);
90
        $this->getGithubPushedAt()->shouldReturn($githubPushedAt);
91
    }
92
}
93