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.

Incrementer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 5
c 4
b 1
f 1
lcom 2
cbo 2
dl 55
loc 55
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnd() 4 4 1
A byDay() 6 6 1
A byWeek() 6 6 1
A byMonth() 6 6 1
A byYear() 6 6 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 Ayaml\Sequence\Calculator\Datetime;
4
5
use Carbon\Carbon;
6
7
/**
8
 * Class Incrementer
9
 *
10
 * @package Ayaml\Sequence\Calculator\Datetime
11
 * @property \Carbon\Carbon end
12
 */
13 View Code Duplication
class Incrementer extends DatetimeCalculator implements DatetimeCalculatorInterface
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...
14
{
15
    /**
16
     * @param string $overwriteVal
17
     * @return bool
18
     */
19
    public function isEnd($overwriteVal)
20
    {
21
        return Carbon::parse($overwriteVal)->gt($this->end);
22
    }
23
24
    /**
25
     * @param null $format
26
     * @return \Ayaml\ContainerCollection
27
     */
28
    public function byDay($format = null)
29
    {
30
        return $this->by(function ($originalDate) {
31
            return Carbon::parse($originalDate)->addDay()->toDateTimeString();
32
        }, $format);
33
    }
34
35
    /**
36
     * @param null $format
37
     * @return \Ayaml\ContainerCollection
38
     */
39
    public function byWeek($format = null)
40
    {
41
        return $this->by(function ($originalDate) {
42
            return Carbon::parse($originalDate)->addWeek()->toDateTimeString();
43
        }, $format);
44
    }
45
46
    /**
47
     * @param null $format
48
     * @return \Ayaml\ContainerCollection
49
     */
50
    public function byMonth($format = null)
51
    {
52
        return $this->by(function ($originalDate) {
53
            return Carbon::parse($originalDate)->addMonth()->toDateTimeString();
54
        }, $format);
55
    }
56
57
    /**
58
     * @param null $format
59
     * @return \Ayaml\ContainerCollection
60
     */
61
    public function byYear($format = null)
62
    {
63
        return $this->by(function ($originalDate) {
64
            return Carbon::parse($originalDate)->addYear()->toDateTimeString();
65
        }, $format);
66
    }
67
}
68