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 — feature/cron_notation_support ( 04bcb2...ddb1da )
by Aleh
01:55
created

CronRule   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 37
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C getRecurrences() 0 26 7
1
<?php
2
3
namespace Scheduler\Job;
4
5
use DateTimeInterface;
6
use Cron\CronExpression;
7
8
/**
9
 * Class CronRule
10
 * @package Scheduler\Job
11
 * @author Aleh Hutnikau, <[email protected]>
12
 */
13
class CronRule extends AbstractRule
14
{
15
16
    /**
17
     * @param DateTimeInterface $from
18
     * @param DateTimeInterface $to
19
     * @param boolean $inc
20
     * @throws
21
     * @return DateTimeInterface[]
22
     */
23 1
    public function getRecurrences(DateTimeInterface $from, DateTimeInterface $to, $inc = true)
24
    {
25 1
        $rRule = CronExpression::factory($this->getRrule());
26 1
        $result = [];
27
28 1
        if ($to->getTimestamp() < $this->getStartDate()->getTimestamp()) {
29 1
            return $result;
30
        }
31
32 1
        if ($from->getTimestamp() < $this->getStartDate()->getTimestamp()) {
33 1
            $from = clone $this->getStartDate();
34
        }
35
36 1
        $firstIteration = true;
37
38
        do {
39 1
            $nextRunDate = $rRule->getNextRunDate($from, 0, $firstIteration && $inc);
40 1
            if ($nextRunDate->getTimestamp() < ($to->getTimestamp() + (int) $inc) && $from->getTimestamp() <= $nextRunDate->getTimestamp()) {
41 1
                $result[] = $nextRunDate;
42
            }
43 1
            $firstIteration = false;
44 1
            $from = $nextRunDate;
45 1
        } while ($nextRunDate->getTimestamp() < ($to->getTimestamp() + (int) $inc));
46
47 1
        return $result;
48
    }
49
}