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.

Job   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 74
ccs 26
cts 26
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRRule() 0 4 1
A getCallable() 0 4 1
A createFromString() 0 14 4
A createRRule() 0 10 2
1
<?php
2
3
namespace Scheduler\Job;
4
5
use DateTimeInterface;
6
use DateTimeZone;
7
use DateTime;
8
9
/**
10
 * Class Job
11
 * @package Job
12
 * @author Aleh Hutnikau, <[email protected]>
13
 */
14
class Job implements JobInterface
15
{
16
    /** @var RRuleInterface */
17
    private $rRule;
18
19
    /** @var callable */
20
    private $callable;
21
22
    /**
23
     * Job constructor.
24
     * @param RRuleInterface $rRule - recurrence rule
25
     * @param callable $callable
26
     */
27 17
    public function __construct(RRuleInterface $rRule, callable $callable)
28
    {
29 17
        $this->rRule = $rRule;
30 17
        $this->callable = $callable;
31 17
    }
32
33
    /**
34
     * @return RRuleInterface
35
     */
36 20
    public function getRRule()
37
    {
38 20
        return $this->rRule;
39
    }
40
41
    /**
42
     * @return callable
43
     */
44 9
    public function getCallable()
45
    {
46 9
        return $this->callable;
47
    }
48
49
    /**
50
     * @param string $rRule RRULE string
51
     * @param string|DateTimeInterface $startDate - @see DateTime supported formats
52
     * @param callable $callback
53
     * @param string|DateTimeZone $timezone - If $timezone is omitted, the current timezone will be used.
54
     *                                        If $startDate is instance of `DateTimeInterface` then $timezone parameter will be ignored
55
     * @return Job
56
     */
57 1
    public static function createFromString($rRule, $startDate, callable $callback, $timezone = null)
58
    {
59 1
        if ($timezone === null) {
60 1
            $timezone = date_default_timezone_get();
61 1
        }
62 1
        if (is_string($timezone)) {
63 1
            $timezone = new DateTimeZone($timezone);
64 1
        }
65 1
        if (!$startDate instanceof DateTimeInterface) {
66 1
            $startDate = new DateTime($startDate, $timezone);
67 1
        }
68 1
        $rRule = self::createRRule($rRule, $startDate);
69 1
        return new self($rRule, $callback);
70
    }
71
72
    /**
73
     * @param $rRule
74
     * @param DateTimeInterface $startDate
75
     * @return RRuleInterface
76
     */
77 1
    protected static function createRRule($rRule, DateTimeInterface $startDate)
78
    {
79
        //select implementation
80 1
        if (stripos($rRule, 'freq=') !== false) {
81 1
            $result = new RRule($rRule, $startDate);
82 1
        } else {
83 1
            $result = new CronRule($rRule, $startDate);
84
        }
85 1
        return $result;
86
    }
87
}