GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Pull Request — master (#18)
by Kristjan
04:07
created

MonthTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 110
Duplicated Lines 41.82 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 2
dl 46
loc 110
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateMonthByAnyDateInRange() 0 7 1
A createMonthByAnyDateInRangeProvider() 0 8 1
A testNextMonth() 0 8 1
A nextMonthProvider() 19 19 1
A testPreviousMonth() 8 8 1
A previousMonthProvider() 19 19 1
A testGetNumberOfDays() 0 5 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\COG\ChronoShifter\Period;
4
5
use COG\ChronoShifter\Period\Month;
6
7
/**
8
 * @author Kristjan Siimson <[email protected]>
9
 * @package Period\Test
10
 */
11
class MonthTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @dataProvider createMonthByAnyDateInRangeProvider
15
     * @param string $date
16
     * @param string $startDate
17
     * @param string $endDate
18
     */
19
    public function testCreateMonthByAnyDateInRange($date, $startDate, $endDate)
20
    {
21
        $month = new Month($date);
22
23
        $this->assertEquals($startDate, $month->getStartDate());
24
        $this->assertEquals($endDate, $month->getEndDate());
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function createMonthByAnyDateInRangeProvider()
31
    {
32
        return array(
33
            array('1999-12-31', '1999-12-01', '1999-12-31'),
34
            array('2000-01-01', '2000-01-01', '2000-01-31'),
35
            array('2000-02-15', '2000-02-01', '2000-02-29')
36
        );
37
    }
38
39
    /**
40
     * @dataProvider nextMonthProvider
41
     * @param string $date
42
     * @param string $startDate
43
     * @param string $endDate
44
     */
45
    public function testNextMonth($date, $startDate, $endDate)
46
    {
47
        $month = new Month($date);
48
        $month->next();
49
50
        $this->assertEquals($startDate, $month->getStartDate());
51
        $this->assertEquals($endDate, $month->getEndDate());
52
    }
53
54
    /**
55
     * @return array
56
     */
57 View Code Duplication
    public function nextMonthProvider()
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...
58
    {
59
        return array(
60
            array('1999-11-30', '1999-12-01', '1999-12-31'),
61
            array('1999-12-31', '2000-01-01', '2000-01-31'),
62
            array('2000-01-15', '2000-02-01', '2000-02-29'),
63
            array('2000-02-01', '2000-03-01', '2000-03-31'),
64
            array('2000-03-01', '2000-04-01', '2000-04-30'),
65
            array('2000-04-01', '2000-05-01', '2000-05-31'),
66
            array('2000-05-01', '2000-06-01', '2000-06-30'),
67
            array('2000-06-01', '2000-07-01', '2000-07-31'),
68
            array('2000-07-01', '2000-08-01', '2000-08-31'),
69
            array('2000-08-01', '2000-09-01', '2000-09-30'),
70
            array('2000-09-01', '2000-10-01', '2000-10-31'),
71
            array('2000-10-01', '2000-11-01', '2000-11-30'),
72
            array('2000-11-01', '2000-12-01', '2000-12-31'),
73
            array('2000-12-01', '2001-01-01', '2001-01-31'),
74
        );
75
    }
76
77
    /**
78
     * @dataProvider previousMonthProvider
79
     * @param string $date
80
     * @param string $startDate
81
     * @param string $endDate
82
     */
83 View Code Duplication
    public function testPreviousMonth($date, $startDate, $endDate)
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...
84
    {
85
        $month = new Month($date);
86
        $month->previous();
87
88
        $this->assertEquals($startDate, $month->getStartDate());
89
        $this->assertEquals($endDate, $month->getEndDate());
90
    }
91
92
    /**
93
     * @return array
94
     */
95 View Code Duplication
    public function previousMonthProvider()
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...
96
    {
97
        return array(
98
            array('1999-11-30', '1999-10-01', '1999-10-31'),
99
            array('1999-12-31', '1999-11-01', '1999-11-30'),
100
            array('2000-01-15', '1999-12-01', '1999-12-31'),
101
            array('2000-02-01', '2000-01-01', '2000-01-31'),
102
            array('2000-03-01', '2000-02-01', '2000-02-29'),
103
            array('2000-04-01', '2000-03-01', '2000-03-31'),
104
            array('2000-05-01', '2000-04-01', '2000-04-30'),
105
            array('2000-06-01', '2000-05-01', '2000-05-31'),
106
            array('2000-07-01', '2000-06-01', '2000-06-30'),
107
            array('2000-08-01', '2000-07-01', '2000-07-31'),
108
            array('2000-09-01', '2000-08-01', '2000-08-31'),
109
            array('2000-10-01', '2000-09-01', '2000-09-30'),
110
            array('2000-11-01', '2000-10-01', '2000-10-31'),
111
            array('2000-12-01', '2000-11-01', '2000-11-30')
112
        );
113
    }
114
115
    public function testGetNumberOfDays()
116
    {
117
        $month = new Month('2015-02-15');
118
        $this->assertEquals(27, $month->getNumberOfDays());
119
    }
120
}
121