SimpleRepoFacadeSpec::let()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 23
rs 9.0856
cc 1
eloc 20
nc 1
nop 9

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 spec\DevBoardLib\GithubObjectApiFacade\Repo;
4
5
use DevBoardLib\GithubApiFacade\Repo\RepoFacade;
6
use DevBoardLib\GithubObjectApiFacade\Repo\Branch\Converter\GithubBranchConverter;
7
use DevBoardLib\GithubObjectApiFacade\Repo\Commit\Converter\GithubCommitConverter;
8
use DevBoardLib\GithubObjectApiFacade\Repo\CommitStatus\Converter\GithubCommitStatusConverter;
9
use DevBoardLib\GithubObjectApiFacade\Repo\Issue\Converter\GithubIssueConverter;
10
use DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConverter;
11
use DevBoardLib\GithubObjectApiFacade\Repo\PullRequest\Converter\GithubPullRequestConverter;
12
use DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter\GithubRepoConverter;
13
use DevBoardLib\GithubObjectApiFacade\Repo\Tag\Converter\GithubTagConverter;
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
17
class SimpleRepoFacadeSpec extends ObjectBehavior
18
{
19
    public function it_is_initializable()
20
    {
21
        $this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\SimpleRepoFacade');
22
        $this->shouldHaveType('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
23
        $this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\ObjectRepoFacade');
24
    }
25
26
    public function let(
27
        RepoFacade $repoFacade,
28
        GithubRepoConverter $githubRepoConverter,
29
        GithubBranchConverter $githubBranchConverter,
30
        GithubTagConverter $githubTagConverter,
31
        GithubPullRequestConverter $githubPullRequestConverter,
32
        GithubCommitConverter $githubCommitConverter,
33
        GithubCommitStatusConverter $githubCommitStatusConverter,
34
        GithubIssueConverter $githubIssueConverter,
35
        GithubMilestoneConverter $githubMilestoneConverter
36
    ) {
37
        $this->beConstructedWith(
38
            $repoFacade,
39
            $githubRepoConverter,
40
            $githubBranchConverter,
41
            $githubTagConverter,
42
            $githubPullRequestConverter,
43
            $githubCommitConverter,
44
            $githubCommitStatusConverter,
45
            $githubIssueConverter,
46
            $githubMilestoneConverter
47
        );
48
    }
49
50 View Code Duplication
    public function it_will_return_all_repo_milestones($repoFacade, $githubMilestoneConverter)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $repoFacade->fetchAllMilestones()->willReturn([['milestone-data']]);
53
54
        $githubMilestoneConverter->convert(['milestone-data'])->willReturn('converted');
55
56
        $this->fetchAllMilestones()->shouldReturn(['converted']);
57
    }
58
59 View Code Duplication
    public function it_will_return_all_repo_issues($repoFacade, $githubIssueConverter)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        $repoFacade->fetchAllIssues()->willReturn([['milestone-data']]);
62
        $githubIssueConverter->convert(['milestone-data'])->willReturn('converted');
63
64
        $this->fetchAllIssues()->shouldReturn(['converted']);
65
    }
66
}
67