GithubMilestoneConverterTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 81.63 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 5
c 2
b 0
f 2
lcom 0
cbo 4
dl 40
loc 49
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testConvert() 11 11 1
A provideConversionData() 10 10 2
A provideTestRepo() 4 4 1
A getDataProvider() 0 4 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 tests\DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter;
4
5
use DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConverter;
6
use Mockery as m;
7
use tests\DevBoardLib\GithubObjectApiFacade\SampleDataProvider;
8
9
/**
10
 * Class GithubMilestoneConverterTest.
11
 */
12 View Code Duplication
class GithubMilestoneConverterTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
13
{
14
    /**
15
     * @dataProvider  provideConversionData
16
     *
17
     * @param array $milestoneData
18
     */
19
    public function testConvert(array $milestoneData)
20
    {
21
        $repo = $this->provideTestRepo();
22
23
        $target = new GithubMilestoneConverter($repo);
24
25
        self::assertInstanceOf(
26
            'DevBoardLib\GithubCore\Milestone\GithubMilestoneSource',
27
            $target->convert($milestoneData)
28
        );
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    public function provideConversionData()
35
    {
36
        $testData = [];
37
38
        foreach ($this->getDataProvider()->getAllMilestones() as $item) {
39
            $testData[] = [$item];
40
        }
41
42
        return $testData;
43
    }
44
45
    /**
46
     * @return m\MockInterface
47
     */
48
    protected function provideTestRepo()
49
    {
50
        return m::mock('DevBoardLib\GithubCore\Repo\GithubRepo');
51
    }
52
53
    /**
54
     * @return SampleDataProvider
55
     */
56
    protected function getDataProvider()
57
    {
58
        return new SampleDataProvider();
59
    }
60
}
61