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.

System   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 63
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getCommand() 0 4 1
A getOutput() 0 4 1
A buildCommand() 0 11 2
A runInForeground() 0 6 1
1
<?php
2
3
namespace Sid\Phalcon\Cron\Job;
4
5
use Sid\Phalcon\Cron\Job;
6
7
class System extends Job
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $command;
13
14
    /**
15
     * @var string
16
     */
17
    protected $output;
18
19
20
21
    public function __construct(string $expression, string $command, string $output = null)
22
    {
23
        parent::__construct($expression);
24
25
        $this->command = $command;
26
        $this->output  = $output;
27
    }
28
29
30
31
    public function getCommand() : string
32
    {
33
        return $this->command;
34
    }
35
36
    /**
37
     * @return string|null
38
     */
39
    public function getOutput()
40
    {
41
        return $this->output;
42
    }
43
44
45
46
    private function buildCommand() : string
47
    {
48
        $command = $this->getCommand();
49
        $output  = $this->getOutput();
50
51
        if ($output) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $output of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
52
            $command .= " > " . $output . " 2>&1";
53
        }
54
55
        return $command;
56
    }
57
58
59
60
    /**
61
     * @return string|null
62
     */
63
    public function runInForeground()
64
    {
65
        return shell_exec(
66
            $this->buildCommand()
67
        );
68
    }
69
}
70