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.
Completed
Push — master ( 930849...205e15 )
by Aleh
11s queued 10s
created

RRule   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 60 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 5
dl 27
loc 45
ccs 19
cts 19
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRecurrences() 13 13 2
A getNextRecurrence() 14 14 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 Scheduler\Job;
4
5
use DateTimeInterface;
6
use Recurr\Rule as RecurrRule;
7
use Recurr\Recurrence;
8
use Recurr\Transformer\ArrayTransformer;
9
use Recurr\Transformer\Constraint\AfterConstraint;
10
use Recurr\Transformer\Constraint\BetweenConstraint;
11
12
/**
13
 * Class RRule
14
 * @package Scheduler\Job
15
 * @author Aleh Hutnikau, <[email protected]>
16
 */
17
class RRule extends AbstractRule
18
{
19
20
    /**
21
     * @param DateTimeInterface $from
22
     * @param DateTimeInterface $to
23
     * @param boolean $inc
24
     * @throws
25
     * @return DateTimeInterface[]
26
     */
27 13 View Code Duplication
    public function getRecurrences(DateTimeInterface $from, DateTimeInterface $to, $inc = true)
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...
28
    {
29 13
        $rRule = new RecurrRule($this->getRrule(), $this->getStartDate());
30 13
        $rRuleTransformer = new ArrayTransformer();
31 13
        $constraint = new BetweenConstraint($from, $to, $inc);
32 13
        $recurrenceCollection = $rRuleTransformer->transform($rRule, $constraint);
33 13
        $result = [];
34
        /** @var Recurrence $recurrence */
35 13
        foreach ($recurrenceCollection as $recurrence) {
36 12
            $result[] = $recurrence->getStart();
37
        }
38 13
        return $result;
39
    }
40
41
    /**
42
     * @param DateTimeInterface $from
43
     * @param boolean $inc including $from and $to dates
44
     * @return DateTimeInterface|null date of the next recurrence or null of no more recurrences scheduled.
45
     * @throws
46
     */
47 1 View Code Duplication
    public function getNextRecurrence(DateTimeInterface $from, $inc = true)
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...
48
    {
49 1
        $rRule = new RecurrRule($this->getRrule(), $this->getStartDate());
50 1
        $rRuleTransformer = new ArrayTransformer();
51 1
        $constraint = new AfterConstraint($from, $inc);
52 1
        $recurrenceCollection = $rRuleTransformer->transform($rRule, $constraint);
53 1
        $result = null;
54
        /** @var Recurrence $recurrence */
55 1
        foreach ($recurrenceCollection as $recurrence) {
56 1
            $result = $recurrence->getStart();
57 1
            break;
58
        }
59 1
        return $result;
60
    }
61
}