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.
Passed
Push — master ( 07b164...660df5 )
by Kristjan
36s
created

ChronoShifterTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 27.54 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 6
dl 19
loc 69
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testChronoShifterImplementsIterator() 0 7 1
A testShifterBeginsFromFirstMatch() 9 9 1
A testShifterIncrementsWithShifter() 10 10 1
A testShifterKeyIsTimestamp() 0 13 1
A testShifterPositionValidForOldDates() 0 7 1
A testShifterPositionValidForFutureDates() 0 7 1
A createIsoChronicIncrement() 0 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\Iterator\ChronoIterator;
4
5
use COG\ChronoShifter\Shifter\ChronoShifter;
6
use COG\ChronoShifter\Direction\Increasing;
7
use COG\ChronoShifter\Period\IsoChronic;
8
use COG\ChronoShifter\Selector\Specific;
9
use COG\ChronoShifter\Iterator\ChronoIterator;
10
11
/**
12
 * @author Kristjan Siimson <[email protected]>
13
 * @package Test
14
 */
15
class ChronoShifterTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function testChronoShifterImplementsIterator()
18
    {
19
        $shifter = $this->createIsoChronicIncrement();
20
        $iterator = new ChronoIterator($shifter, '2015-01-03');
21
22
        $this->assertInstanceOf('\Iterator', $iterator);
23
    }
24
25 View Code Duplication
    public function testShifterBeginsFromFirstMatch()
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...
26
    {
27
        $shifter = $this->createIsoChronicIncrement();
28
29
        $iterator = new ChronoIterator($shifter, '2015-01-03');
30
        $result = $iterator->current();
31
32
        $this->assertEquals('2015-01-15', $result);
33
    }
34
35 View Code Duplication
    public function testShifterIncrementsWithShifter()
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...
36
    {
37
        $shifter = $this->createIsoChronicIncrement();
38
39
        $iterator = new ChronoIterator($shifter, '2015-01-03');
40
        $iterator->next();
41
        $result = $iterator->current();
42
43
        $this->assertEquals('2015-01-29', $result);
44
    }
45
46
    public function testShifterKeyIsTimestamp()
47
    {
48
        $shifter = $this->createIsoChronicIncrement();
49
50
        $iterator = new ChronoIterator($shifter, '2015-01-03');
51
        $iterator->next();
52
53
        $date = new \DateTime();
54
        $date->setTimezone(new \DateTimeZone('Europe/Helsinki'));
55
        $date->setDate(2015, 01, 15)->setTime(0, 0, 0);
56
57
        $this->assertInternalType('integer', $iterator->key());
58
    }
59
60
    public function testShifterPositionValidForOldDates()
61
    {
62
        $shifter = $this->createIsoChronicIncrement();
63
        $iterator = new ChronoIterator($shifter, '1988-09-01');
64
65
        $this->assertTrue($iterator->valid());
66
    }
67
68
    public function testShifterPositionValidForFutureDates()
69
    {
70
        $shifter = $this->createIsoChronicIncrement();
71
        $iterator = new ChronoIterator($shifter, '2100-09-01');
72
73
        $this->assertTrue($iterator->valid());
74
    }
75
76
    /**
77
     * @return ChronoShifter
78
     */
79
    private function createIsoChronicIncrement()
80
    {
81
        return new ChronoShifter(new Isochronic('2015-01-01', '2015-01-01', 14), new Specific(new Increasing(), 1));
82
    }
83
}
84