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
Branch master (c91cad)
by Aleh
02:07
created

Job::createFromString()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 4
crap 3
1
<?php
2
3
namespace Scheduler\Job;
4
5
use Recurr\Rule;
6
use DateTimeInterface;
7
use DateTimeZone;
8
use DateTime;
9
10
/**
11
 * Class Job
12
 * @package Job
13
 * @author Aleh Hutnikau, <[email protected]>
14
 */
15
class Job implements JobInterface
16
{
17
    /** @var Rule */
18
    private $rRule;
19
20
    /** @var callable */
21
    private $callable;
22
23
    /**
24
     * Job constructor.
25
     * @param Rule $rRule - recurrence rules (@see https://github.com/simshaun/recurr)
26
     * @param callable $callable
27
     */
28 8
    public function __construct(Rule $rRule, callable $callable)
29
    {
30 8
        $this->rRule = $rRule;
31 8
        $this->callable = $callable;
32 8
    }
33
34
    /**
35
     * @return Rule
36
     */
37 15
    public function getRRule()
38
    {
39 15
        return $this->rRule;
40
    }
41
42
    /**
43
     * @return callable
44
     */
45 2
    public function getCallable()
46
    {
47 2
        return $this->callable;
48
    }
49
50
    /**
51
     * @param string $rRule RRULE string
52
     * @param string|DateTimeInterface $startDate - @see DateTime supported formats
53
     * @param callable $callback
54
     * @param string|DateTimeZone $timezone - If $timezone is omitted, the current timezone will be used.
55
     * @return Job
56
     */
57 1
    public static function createFromString($rRule, $startDate, callable $callback, $timezone = null)
58
    {
59 1
        if (!$startDate instanceof DateTimeInterface) {
60 1
            $startDate = new DateTime($startDate, new \DateTimeZone($timezone));
61
        }
62 1
        if (empty($timezone)) {
63 1
            $timezone = $startDate->getTimezone()->getName();
64
        }
65 1
        $rRule = new Rule($rRule, $startDate, null, $timezone);
66 1
        return new self($rRule, $callback);
67
    }
68
}