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.

MonthlyLastWorkdayIncrementTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 82
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 82
loc 82
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\Increasing;
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 MonthlyLastWorkdayIncrementTest 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 before last workday of month, shift to next day
24
25
        array(
26
            '2015-03-30 23:59:59', // Starting time
27
            '2015-03-31'  // Expected time
28
        ),
29
30
        // Start at first second of the day after last workday of month, shift forward by a month
31
32
        array(
33
            '2015-03-31 23:59:59', // Starting time
34
            '2015-04-30', // Expected time
35
        ),
36
37
        // Shift over holidays
38
39
        array(
40
            '2015-03-30 15:12:24', // Starting time
41
            '2015-04-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-06-30'  // Expected time
52
        ),
53
54
        // Start at first second of last working day of month
55
        // Last working day of next month is a Monday, but it's a holiday
56
        // Shift over the weekend to Friday of the next month
57
58
        array(
59
            '2015-07-31', // Starting time
60
            '2015-08-28', // Expected time
61
            array(
62
                '2015-08-31'       // Holidays
63
            )
64
        )
65
66
    );
67
68
    /**
69
     * @dataProvider shiftProvider
70
     * @param string $start
71
     * @param string $expected
72
     * @param string[] $holidays
73
     */
74
    public function testShift($start, $expected, $holidays = array())
75
    {
76
        $shifter = new ChronoShifter(new Month($start),
77
            new LastOf(new Increasing(), new Workday(new ArrayHolidayProvider($holidays))));
78
        $result = $shifter->shift($start);
79
80
        $this->assertEquals(
81
            $expected,
82
            $result,
83
            sprintf(
84
                'From %s to next last workday of month ',
85
                $start
86
            )
87
        );
88
    }
89
90
    /**
91
     * @return array
92
     */
93
    public function shiftProvider()
94
    {
95
        return $this->fixture;
96
    }
97
}
98