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::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Sid\Phalcon\Cron;
4
5
use Cron\CronExpression;
6
use DateTime;
7
use Phalcon\Di\Injectable;
8
9
abstract class Job extends Injectable implements \Sid\Cron\JobInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $expression;
15
16
17
18
    public function __construct(string $expression)
19
    {
20
        $this->expression = $expression;
21
    }
22
23
24
25
    public function getExpression() : string
26
    {
27
        return $this->expression;
28
    }
29
30
31
32
    public function isDue(DateTime $datetime = null) : bool
33
    {
34
        $cronExpression = CronExpression::factory(
35
            $this->getExpression()
36
        );
37
38
        return $cronExpression->isDue($datetime);
0 ignored issues
show
Bug introduced by
It seems like $datetime defined by parameter $datetime on line 32 can be null; however, Cron\CronExpression::isDue() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
39
    }
40
41
42
43
    /**
44
     * @return mixed
45
     */
46
    abstract public function runInForeground();
47
48
    /**
49
     * @throws Exception
50
     */
51
    public function runInBackground() : Process
52
    {
53
        $processID = pcntl_fork();
54
55
        if ($processID === -1) {
56
            throw new Exception(
57
                "Failed to fork process."
58
            );
59
        }
60
61
        // This is the child process.
62
        if ($processID === 0) {
63
            // @codeCoverageIgnoreStart
64
            $this->runInForeground();
65
66
            exit(0);
67
            // @codeCoverageIgnoreEnd
68
        }
69
70
        $process = new Process($processID);
71
72
        return $process;
73
    }
74
}
75