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.

MonthlyFirstWorkdayIncrementTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 75
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 2
c 5
b 1
f 1
lcom 0
cbo 7
dl 75
loc 75
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\FirstOf;
10
use COG\ChronoShifter\Shifter\ChronoShifter;
11
12
/**
13
 * @author Kristjan Siimson <[email protected]>
14
 * @package Shifter\Test
15
 */
16 View Code Duplication
class MonthlyFirstWorkdayIncrementTest 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 first workday of month, shift to next day
24
25
        array(
26
            '2015-05-31 23:59:59', // Starting time
27
            '2015-06-01', // Expected time
28
        ),
29
30
        // Start at first second of the day after first workday of month, shift forward by a month
31
32
        array(
33
            '2015-06-01', // Starting time
34
            '2015-07-01', // Expected time
35
        ),
36
37
        array(
38
            '2015-07-31 15:12:24', // Starting time
39
            '2015-08-03', // Expected time
40
        ),
41
42
        array(
43
            '2015-03-01', // Starting time
44
            '2015-03-04', // Expected time
45
            [
46
                '2015-03-02',      // Holidays
47
                '2015-03-03'
48
            ]
49
        ),
50
51
        array(
52
            '2015-10-31', // Starting time
53
            '2015-11-02', // Expected time
54
            [
55
                '2015-10-01',      // Holidays
56
                '2015-10-02'
57
            ]
58
        )
59
    );
60
61
    /**
62
     * @dataProvider shiftProvider
63
     * @param string $start
64
     * @param string $expected
65
     * @param string[] $holidays
66
     */
67
    public function testShift($start, $expected, $holidays = array())
68
    {
69
        $shifter = new ChronoShifter(new Month($start),
70
            new FirstOf(new Increasing(), new Workday(new ArrayHolidayProvider($holidays))));
71
        $result = $shifter->shift($start);
72
73
        $this->assertEquals(
74
            $expected,
75
            $result,
76
            sprintf(
77
                'From %s to next first workday of month ',
78
                $start
79
            )
80
        );
81
    }
82
83
    /**
84
     * @return array
85
     */
86
    public function shiftProvider()
87
    {
88
        return $this->fixture;
89
    }
90
}
91