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.

MonthlyLastWorkdayDecrementTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 81
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testShift() 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\Evaluator\Workday;
7
use COG\ChronoShifter\HolidayProvider\ArrayHolidayProvider;
8
use COG\ChronoShifter\Period\Month;
9
use COG\ChronoShifter\Selector\LastOf;
10
use COG\ChronoShifter\Shifter\ChronoShifter;
11
12
/**
13
 * @author Kristjan Siimson <[email protected]>
14
 * @package Shifter\Test
15
 */
16 View Code Duplication
class MonthlyLastWorkdayDecrementTest 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...
17
{
18
    /**
19
     * @var array
20
     */
21
    private $fixture = array(
22
23
        // Start at one second after last workday of month, shift to previous day
24
25
        array(
26
            '2015-04-01', // Starting time
27
            '2015-03-31'  // Expected time
28
        ),
29
30
        // Start at last second of last workday of month, shift back by a month
31
32
        array(
33
            '2015-03-31 23:59:59', // Starting time
34
            '2015-02-27', // Expected time
35
        ),
36
37
        // Shift over holidays
38
39
        array(
40
            '2015-04-01 15:12:24', // Starting time
41
            '2015-03-30', // Expected time
42
            array(
43
                '2015-03-31'       // Holidays
44
            )
45
        ),
46
47
        // Start in the middle of a month
48
49
        array(
50
            '2015-06-15', // Starting time
51
            '2015-05-29'  // Expected time
52
        ),
53
54
        // Start one second before last working day of month
55
        // Last working day of previous month is a Monday, but it's a holiday
56
        // Shift over the weekend to Friday of last month
57
58
        array(
59
            '2015-09-29 23:59:59', // Starting time
60
            '2015-08-28', // Expected time
61
            array(
62
                '2015-08-31'       // Holidays
63
            )
64
        )
65
    );
66
67
    /**
68
     * @dataProvider shiftProvider
69
     * @param string $start
70
     * @param string $expected
71
     * @param string[] $holidays
72
     */
73
    public function testShift($start, $expected, $holidays = array())
74
    {
75
        $shifter = new ChronoShifter(new Month($start),
76
            new LastOf(new Decreasing(), new Workday(new ArrayHolidayProvider($holidays))));
77
        $result = $shifter->shift($start);
78
79
        $this->assertEquals(
80
            $expected,
81
            $result,
82
            sprintf(
83
                'From %s to previous last workday of month ',
84
                $start
85
            )
86
        );
87
    }
88
89
    /**
90
     * @return array
91
     */
92
    public function shiftProvider()
93
    {
94
        return $this->fixture;
95
    }
96
}
97