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 ( 660df5...3fb9ca )
by Kristjan
05:20 queued 02:18
created

LastTo   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 28
loc 28
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A shift() 8 8 2

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 COG\ChronoShifter\Shifter;
4
5
use COG\ChronoShifter\Evaluator\Evaluator;
6
7
/**
8
 * @author Kristjan Siimson <[email protected]>
9
 * @package Shifter\Domain
10
 */
11 View Code Duplication
class LastTo implements Shifter
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...
12
{
13
    /**
14
     * @var Evaluator
15
     */
16
    private $evaluator;
17
18
    /**
19
     * @param Evaluator $evaluator
20
     */
21 2
    public function __construct(Evaluator $evaluator)
22
    {
23 2
        $this->evaluator = $evaluator;
24 2
    }
25
26
    /**
27
     * @param string $date
28
     * @return string
29
     */
30 2
    public function shift($date)
31
    {
32 2
        while (!$this->evaluator->is($date)) {
33 1
            $date = date('Y-m-d', strtotime('-1 day', strtotime($date)));
34 1
        }
35
36 2
        return $date;
37
    }
38
}
39