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.

IsochronicDecrementTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 101
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 7
Bugs 3 Features 1
Metric Value
wmc 2
c 7
b 3
f 1
lcom 0
cbo 5
dl 101
loc 101
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testShiftDown() 15 15 1
A shiftProvider() 4 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\COG\ChronoShifter\Shifter;
4
5
use COG\ChronoShifter\Direction\Decreasing;
6
use COG\ChronoShifter\Period\IsoChronic;
7
use COG\ChronoShifter\Selector\Specific;
8
use COG\ChronoShifter\Shifter\ChronoShifter;
9
10
/**
11
 * @author Kristjan Siimson <[email protected]>
12
 * @package Shifter\Test
13
 */
14 View Code Duplication
class IsochronicDecrementTest 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...
15
{
16
    /**
17
     * @var array
18
     */
19
    private $fixture = array(
20
21
        // Shift down by four weeks
22
        array(
23
            '2015-07-01', // Day of reference
24
            '2015-07-01', // Starting time
25
            '2015-06-03'  // Expected time
26
        ),
27
28
        // Discard time of the day
29
        array(
30
            '2015-07-01', // Day of reference
31
            '2015-07-01 15:12:24', // Starting time
32
            '2015-06-03'  // Expected time
33
        ),
34
35
        // Reference date in future
36
        array(
37
            '2015-07-02', // Day of reference
38
            '2015-07-01', // Starting time
39
            '2015-06-04'  // Expected time
40
        ),
41
42
        // Reference date on the previous day
43
        array(
44
            '2015-06-30', // Day of reference
45
            '2015-07-01', // Starting time
46
            '2015-06-30'  // Expected time
47
        ),
48
49
        // Reference date on the next day
50
        array(
51
            '2015-06-26 15:12:24', // Day of reference
52
            '2015-06-25', // Starting time
53
            '2015-05-29'  // Expected time
54
        ),
55
56
        // February with 28 days
57
        array(
58
            '2015-03-28', // Day of reference
59
            '2015-03-15', // Starting time
60
            '2015-02-28'  // Expected time
61
        ),
62
63
        // February with 29 days
64
        array(
65
            '2016-03-28', // Day of reference
66
            '2016-03-15', // Starting time
67
            '2016-02-29'  // Expected time
68
        ),
69
70
        // Decrement with DST difference
71
        array(
72
            '2015-04-05 10:26:20', // Day of reference
73
            '2015-04-01', // Starting time
74
            '2015-03-08'  // Expected time
75
        ),
76
77
        // Decrement with DST difference
78
        array(
79
            '2015-04-05 10:26:20', // Day of reference
80
            '2015-11-12', // Starting time
81
            '2015-10-18'  // Expected time
82
        )
83
    );
84
85
    /**
86
     * @dataProvider shiftProvider
87
     * @param integer $reference
88
     * @param string $start
89
     * @param string $expected
90
     */
91
    public function testShiftDown($reference, $start, $expected)
92
    {
93
        $shifter = new ChronoShifter(new Isochronic($start, $reference, 28), new Specific(new Decreasing(), 1));
94
        $result = $shifter->shift($start);
95
96
        $this->assertEquals(
97
            $expected,
98
            $result,
99
            sprintf(
100
                'From %s to previous four weeks referencing %s',
101
                $start,
102
                $reference
103
            )
104
        );
105
    }
106
107
    /**
108
     * @return array
109
     */
110
    public function shiftProvider()
111
    {
112
        return $this->fixture;
113
    }
114
}
115