Test Failed
Pull Request — master (#7)
by Jim
03:47
created

TaskEvent   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 200
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 54.05%

Importance

Changes 0
Metric Value
wmc 15
lcom 0
cbo 0
dl 0
loc 200
rs 10
c 0
b 0
f 0
ccs 20
cts 37
cp 0.5405

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getTaskName() 0 4 1
A setTaskName() 0 5 1
A getPayload() 0 4 1
A setPayload() 0 5 1
A getInitiatedAt() 0 4 1
A setInitiatedAt() 0 5 1
A getCompletedAt() 0 4 1
A setCompletedAt() 0 5 1
A getFailedAt() 0 4 1
A setFailedAt() 0 5 1
A getErrors() 0 4 1
A setErrors() 0 6 1
A getTargetTime() 0 4 1
A setTargetTime() 0 6 1
1
<?php
2
3
4
namespace Jarobe\TaskRunnerBundle\Entity;
5
6
use Doctrine\ORM\Mapping as ORM;
7
8
/**
9
 * @ORM\Table(name="task_event")
10
 * @ORM\Entity()
11
 */
12
class TaskEvent
13
{
14
    /**
15
     * @var integer
16
     *
17
     * @ORM\Column(name="id", type="integer")
18
     * @ORM\Id
19
     * @ORM\GeneratedValue(strategy="AUTO")
20
     */
21
    private $id;
22
23
    /**
24
     * @var string
25
     *
26
     * @ORM\Column(name="task_name", type="string", length=100)
27
     */
28
    private $taskName;
29
30
31
    /**
32
     * Many of the Tasks that are run have a specified time that they run for. Because of this, we store the TargetTime
33
     * outside of the payload. This helps significantly with querying what commands have been run for a date, as well.
34
     *
35
     * @var \DateTime
36
     *
37
     * @ORM\Column(name="target_time", type="datetime", nullable=true)
38
     */
39
    private $targetTime;
40
41
    /**
42
     * @var array
43
     *
44
     * @ORM\Column(name="payload", type="array")
45
     */
46
    private $payload;
47
48
    /**
49
     * @var \DateTime
50
     *
51
     * @ORM\Column(name="initiated_at", type="datetime", nullable=true)
52
     */
53
    private $initiatedAt;
54
55
    /**
56
     * @var \DateTime
57
     *
58
     * @ORM\Column(name="failed_at", type="datetime", nullable=true)
59
     */
60
    private $failedAt;
61
62
    /**
63
     * @var \DateTime
64
     *
65
     * @ORM\Column(name="completed_at", type="datetime", nullable=true)
66
     */
67
    private $completedAt;
68
69
    /**
70
     * @var array
71
     *
72
     * @ORM\Column(name="errors", type="json_array", nullable=true)
73
     */
74
    private $errors;
75
76
    /**
77
     * @return int
78
     */
79
    public function getId()
80
    {
81
        return $this->id;
82
    }
83
84
    /**
85
     * @return string
86
     */
87
    public function getTaskName()
88
    {
89
        return $this->taskName;
90
    }
91
92
    /**
93
     * @param string $taskName
94
     * @return TaskEvent
95
     */
96
    public function setTaskName($taskName)
97
    {
98
        $this->taskName = $taskName;
99
        return $this;
100
    }
101
102
    /**
103
     * @return array
104
     */
105
    public function getPayload()
106
    {
107
        return $this->payload;
108
    }
109
110
    /**
111
     * @param array $payload
112
     * @return TaskEvent
113
     */
114
    public function setPayload($payload)
115
    {
116
        $this->payload = $payload;
117
        return $this;
118
    }
119
120
    /**
121
     * @return \DateTime
122
     */
123 1
    public function getInitiatedAt()
124
    {
125 1
        return $this->initiatedAt;
126
    }
127
128
    /**
129
     * @param \DateTime $initiatedAt
130
     * @return TaskEvent
131
     */
132 1
    public function setInitiatedAt(\DateTime $initiatedAt)
133
    {
134 1
        $this->initiatedAt = $initiatedAt;
135 1
        return $this;
136
    }
137
138
    /**
139
     * @return \DateTime
140
     */
141 2
    public function getCompletedAt()
142
    {
143 2
        return $this->completedAt;
144
    }
145
146
    /**
147
     * @param \DateTime $completedAt
148
     * @return TaskEvent
149
     */
150 2
    public function setCompletedAt(\DateTime $completedAt)
151
    {
152 2
        $this->completedAt = $completedAt;
153 2
        return $this;
154
    }
155
156
    /**
157
     * @return \DateTime
158
     */
159 2
    public function getFailedAt()
160
    {
161 2
        return $this->failedAt;
162
    }
163
164
    /**
165
     * @param $failedAt
166
     * @return $this
167
     */
168 2
    public function setFailedAt(\DateTime $failedAt)
169
    {
170 2
        $this->failedAt = $failedAt;
171 2
        return $this;
172
    }
173
174
    /**
175
     * @return array
176
     */
177 4
    public function getErrors()
178
    {
179 4
        return $this->errors;
180
    }
181
182
    /**
183
     * @param array|null $errors
184
     * @return $this
185
     */
186 4
    public function setErrors(array $errors = null)
187
    {
188 4
        $this->errors = $errors;
0 ignored issues
show
Documentation Bug introduced by
It seems like $errors can be null. However, the property $errors is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
189
190 4
        return $this;
191
    }
192
193
    /**
194
     * @return \DateTime
195
     */
196
    public function getTargetTime()
197
    {
198
        return $this->targetTime;
199
    }
200
201
    /**
202
     * @param \DateTime $targetTime
203
     * @return $this
204
     */
205
    public function setTargetTime($targetTime = null)
206
    {
207
        $this->targetTime = $targetTime;
208
209
        return $this;
210
    }
211
}
212