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   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 168
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 95.65%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 18
lcom 1
cbo 1
dl 0
loc 168
ccs 44
cts 46
cp 0.9565
rs 10
c 2
b 1
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 24 6
A getSimpleArrayCopy() 0 11 4
A isSchedulingJob() 0 4 2
A isDependencyJob() 0 4 2
B jsonSerialize() 0 26 3
A getIterator() 0 4 1
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