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
Pull Request — master (#68)
by Bidesh
03:32
created

ChronosJobEntity::isSchedulingJob()   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
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
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
13
use Chapi\Entity\Chronos\JobEntity\ContainerEntity;
14
use Chapi\Entity\JobEntityInterface;
15
16
class ChronosJobEntity implements JobEntityInterface
17
{
18
    public $name = '';
19
20
    public $command = '';
21
22
    public $description = '';
23
24
    public $owner = '';
25
26
    public $ownerName = '';
27
28
    public $schedule = ''; // todo: move to separate entity
29
30
    public $scheduleTimeZone = '';
31
32
    public $parents = []; // todo: move to separate entity
33
34
    public $epsilon = '';
35
36
    public $executor = '';
37
38
    public $executorFlags = '';
39
40
    public $shell = true;
41
42
    public $retries = 0;
43
44
    public $async = false;
45
46
    public $successCount = 0;
47
48
    public $errorCount = 0;
49
50
    public $errorsSinceLastSuccess = 0;
51
52
    public $lastSuccess = '';
53
54
    public $lastError = '';
55
56
    public $cpus = 0.1;
57
58
    public $disk = 24;
59
60
    public $mem = 32;
61
62
    public $disabled = false;
63
64
    public $softError = false;
65
66
    public $dataProcessingJobType = false;
67
68
    public $uris = [];
69
70
    public $environmentVariables = [];
71
72
    public $arguments = [];
73
74
    public $highPriority = false;
75
76
    public $runAsUser = 'root';
77
78
    public $constraints = [];
79
80
    /** @var ContainerEntity */
81
    public $container = null;
82
83
84
    /**
85
     * @param array|object $mJobData
86
     * @throws \InvalidArgumentException
87
     */
88 115
    public function __construct($mJobData = [])
89
    {
90 115
        if (is_array($mJobData) || is_object($mJobData))
91 115
        {
92 114
            foreach ($mJobData as $_sKey => $_mValue)
93
            {
94 17
                if (property_exists($this, $_sKey))
95 17
                {
96 17
                    if ($_sKey == 'container')
97 17
                    {
98 2
                        $this->{$_sKey} = new ContainerEntity($_mValue);
99 1
                    }
100
                    else
101
                    {
102 17
                        $this->{$_sKey} = $_mValue;    
103
                    }
104 17
                }
105 114
            }
106 113
        }
107
        else
108
        {
109 1
            throw new \InvalidArgumentException(sprintf('Argument 1 passed to "%s" must be an array or object', __METHOD__));
110
        }
111 113
    }
112
113
    /**
114
     * return entity as one-dimensional array
115
     *
116
     * @return mixed[]
117
     */
118 8 View Code Duplication
    public function getSimpleArrayCopy()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
119
    {
120 8
        $_aReturn = [];
121
122 8
        foreach ($this as $_sProperty => $mValue)
123
        {
124 8
            $_aReturn[$_sProperty] = (is_array($mValue) || is_object($mValue)) ? json_encode($mValue) : $mValue;
125 8
        }
126
127 8
        return $_aReturn;
128
    }
129
130
    /**
131
     * @return bool
132
     */
133 18
    public function isSchedulingJob()
134
    {
135 18
        return (!empty($this->schedule) && empty($this->parents));
136
    }
137
138
    /**
139
     * @return bool
140
     */
141 7
    public function isDependencyJob()
142
    {
143 7
        return (empty($this->schedule) && !empty($this->parents));
144
    }
145
146
    /**
147
     * @return array
148
     */
149 11
    public function jsonSerialize()
150
    {
151 11
        $_aReturn = (array) $this;
152 11
        if (!empty($this->schedule))
153 11
        {
154 10
            unset($_aReturn['parents']);
155 10
        }
156
        else
157
        {
158 1
            unset($_aReturn['schedule']);
159 1
            unset($_aReturn['scheduleTimeZone']);
160
        }
161
162 11
        if (empty($this->container))
163 11
        {
164 11
            unset($_aReturn['container']);
165 11
        }
166
167 11
        unset($_aReturn['successCount']);
168 11
        unset($_aReturn['errorCount']);
169 11
        unset($_aReturn['errorsSinceLastSuccess']);
170 11
        unset($_aReturn['lastSuccess']);
171 11
        unset($_aReturn['lastError']);
172
173 11
        return $_aReturn;
174
    }
175
176
    /**
177
     * @return \ArrayIterator
178
     */
179 9
    public function getIterator()
180
    {
181 9
        return new \ArrayIterator($this);
182
    }
183
184
    /**
185
     * @return string
186
     */
187 5
    public function getEntityType()
188
    {
189 5
        return JobEntityInterface::CHRONOS_TYPE;
190
    }
191
192
    /**
193
     * @return string
194
     */
195 40
    public function getKey()
196
    {
197 40
        return $this->name;
198
    }
199
}
200