SimpleRepoFacadeSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 30 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 0
cbo 1
dl 15
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 6 1
A let() 0 23 1
A it_will_return_all_repo_milestones() 8 8 1
A it_will_return_all_repo_issues() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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