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 feature/add_container_job_supp... (565db8)
by Marc
04:48
created

JobEntity::isDependencyJob()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-07-29
7
 *
8
 */
9
10
namespace Chapi\Entity\Chronos;
11
12
use Chapi\Entity\Chronos\JobEntity\ContainerEntity;
13
14
class JobEntity implements JobEntityInterface
15
{
16
    public $name = '';
17
18
    public $command = '';
19
20
    public $description = '';
21
22
    public $owner = '';
23
24
    public $ownerName = '';
25
26
    public $schedule = ''; // todo: move to separate entity
27
28
    public $scheduleTimeZone = '';
29
30
    public $parents = []; // todo: move to separate entity
31
32
    public $epsilon = '';
33
34
    public $executor = '';
35
36
    public $executorFlags = '';
37
38
    public $shell = true;
39
40
    public $retries = 0;
41
42
    public $async = false;
43
44
    public $successCount = 0;
45
46
    public $errorCount = 0;
47
48
    public $errorsSinceLastSuccess = 0;
49
50
    public $lastSuccess = '';
51
52
    public $lastError = '';
53
54
    public $cpus = 0.1;
55
56
    public $disk = 24;
57
58
    public $mem = 32;
59
60
    public $disabled = false;
61
62
    public $softError = false;
63
64
    public $dataProcessingJobType = false;
65
66
    public $uris = [];
67
68
    public $environmentVariables = [];
69
70
    public $arguments = [];
71
72
    public $highPriority = false;
73
74
    public $runAsUser = 'root';
75
76
    public $constraints = [];
77
78
    /** @var ContainerEntity */
79
    public $container = null;
80
81
82
    /**
83
     * @param array|object $mJobData
84
     * @throws \InvalidArgumentException
85
     */
86 83
    public function __construct($mJobData = [])
87
    {
88 83
        if (is_array($mJobData) || is_object($mJobData))
89 83
        {
90 82
            foreach ($mJobData as $_sKey => $_mValue)
91
            {
92 14
                if (property_exists($this, $_sKey))
93 14
                {
94 14
                    if ($_sKey == 'container')
95 14
                    {
96
                        $this->{$_sKey} = new ContainerEntity($_mValue);
97
                    }
98
                    else
99
                    {
100 14
                        $this->{$_sKey} = $_mValue;    
101
                    }
102 14
                }
103 82
            }
104 82
        }
105
        else
106
        {
107 1
            throw new \InvalidArgumentException(sprintf('Argument 1 passed to "%s" must be an array or object', __METHOD__));
108
        }
109 82
    }
110
111
    /**
112
     * return entity as one-dimensional array
113
     *
114
     * @return mixed[]
115
     */
116 8
    public function getSimpleArrayCopy()
117
    {
118 8
        $_aReturn = [];
119
120 8
        foreach ($this as $_sProperty => $mValue)
121
        {
122 8
            $_aReturn[$_sProperty] = (is_array($mValue) || is_object($mValue)) ? json_encode($mValue) : $mValue;
123 8
        }
124
125 8
        return $_aReturn;
126
    }
127
128
    /**
129
     * @return bool
130
     */
131 27
    public function isSchedulingJob()
132
    {
133 27
        return (!empty($this->schedule) && empty($this->parents));
134
    }
135
136
    /**
137
     * @return bool
138
     */
139 7
    public function isDependencyJob()
140
    {
141 7
        return (empty($this->schedule) && !empty($this->parents));
142
    }
143
144
    /**
145
     * @return array
146
     */
147 7
    public function jsonSerialize()
148
    {
149 7
        $_aReturn = (array) $this;
150 7
        if (!empty($this->schedule))
151 7
        {
152 6
            unset($_aReturn['parents']);
153 6
        }
154
        else
155
        {
156 1
            unset($_aReturn['schedule']);
157 1
            unset($_aReturn['scheduleTimeZone']);
158
        }
159
160 7
        if (empty($this->container))
161 7
        {
162 7
            unset($_aReturn['container']);
163 7
        }
164
165 7
        unset($_aReturn['successCount']);
166 7
        unset($_aReturn['errorCount']);
167 7
        unset($_aReturn['errorsSinceLastSuccess']);
168 7
        unset($_aReturn['lastSuccess']);
169 7
        unset($_aReturn['lastError']);
170
171 7
        return $_aReturn;
172
    }
173
174
    /**
175
     * @return \ArrayIterator
176
     */
177 20
    public function getIterator()
178
    {
179 20
        return new \ArrayIterator($this);
180
    }
181
}
182