Completed
Push — master ( 9e8f3a...aad910 )
by Wachter
05:44
created

TaskExecution::getHandlerClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\Execution;
13
14
use Ramsey\Uuid\Uuid;
15
use Task\TaskInterface;
16
17
/**
18
 * Single task-execution.
19
 */
20
class TaskExecution implements TaskExecutionInterface
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $uuid;
26
27
    /**
28
     * @var TaskInterface
29
     */
30
    protected $task;
31
32
    /**
33
     * @var \Serializable|string
34
     */
35
    protected $workload;
36
37
    /**
38
     * @var string
39
     */
40
    protected $handlerClass;
41
42
    /**
43
     * @var \DateTime
44
     */
45
    protected $scheduleTime;
46
47
    /**
48
     * @var \DateTime
49
     */
50
    protected $startTime;
51
52
    /**
53
     * @var \DateTime
54
     */
55
    protected $endTime;
56
57
    /**
58
     * @var float
59
     */
60
    protected $duration;
61
62
    /**
63
     * @var string
64
     */
65
    protected $status;
66
67
    /**
68
     * @var string|\Serializable
69
     */
70
    protected $result;
71
72
    /**
73
     * @var string
74
     */
75
    protected $exception;
76
77
    /**
78
     * @param TaskInterface $task
79
     * @param $handlerClass
80
     * @param \DateTime $scheduleTime
81
     * @param string|\Serializable $workload
82
     * @param string $uuid
83
     */
84 17 View Code Duplication
    public function __construct(
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...
85
        TaskInterface $task,
86
        $handlerClass,
87
        \DateTime $scheduleTime,
88
        $workload = null,
89
        $uuid = null
90
    ) {
91 17
        $this->uuid = $uuid ?: Uuid::uuid4()->toString();
92 17
        $this->task = $task;
93 17
        $this->handlerClass = $handlerClass;
94 17
        $this->scheduleTime = $scheduleTime;
95 17
        $this->workload = $workload;
96 17
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101 1
    public function getUuid()
102
    {
103 1
        return $this->uuid;
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109 4
    public function getTask()
110
    {
111 4
        return $this->task;
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117 3
    public function getWorkload()
118
    {
119 3
        return $this->workload;
120
    }
121
122
    /**
123
     * {@inheritdoc}
124
     */
125 3
    public function getHandlerClass()
126
    {
127 3
        return $this->handlerClass;
128
    }
129
130
    /**
131
     * {@inheritdoc}
132
     */
133 4
    public function getScheduleTime()
134
    {
135 4
        return $this->scheduleTime;
136
    }
137
138
    /**
139
     * {@inheritdoc}
140
     */
141 3
    public function setStartTime(\DateTime $startTime)
142
    {
143 3
        $this->startTime = $startTime;
144
145 3
        return $this;
146
    }
147
148
    /**
149
     * {@inheritdoc}
150
     */
151 3
    public function setEndTime(\DateTime $endTime)
152
    {
153 3
        $this->endTime = $endTime;
154
155 3
        return $this;
156
    }
157
158
    /**
159
     * {@inheritdoc}
160
     */
161 3
    public function setDuration($duration)
162
    {
163 3
        $this->duration = $duration;
164
165 3
        return $this;
166
    }
167
168
    /**
169
     * {@inheritdoc}
170
     */
171 3
    public function getStartTime()
172
    {
173 3
        return $this->startTime;
174
    }
175
176
    /**
177
     * {@inheritdoc}
178
     */
179 3
    public function getEndTime()
180
    {
181 3
        return $this->endTime;
182
    }
183
184
    /**
185
     * {@inheritdoc}
186
     */
187 3
    public function getDuration()
188
    {
189 3
        return $this->duration;
190
    }
191
192
    /**
193
     * {@inheritdoc}
194
     */
195 5
    public function getStatus()
196
    {
197 5
        return $this->status;
198
    }
199
200
    /**
201
     * {@inheritdoc}
202
     */
203 3
    public function getResult()
204
    {
205 3
        return $this->result;
206
    }
207
208
    /**
209
     * {@inheritdoc}
210
     */
211 2
    public function getException()
212
    {
213 2
        return $this->exception;
214
    }
215
216
    /**
217
     * {@inheritdoc}
218
     */
219 5
    public function setStatus($status)
220
    {
221 5
        $this->status = $status;
222
223 5
        return $this;
224
    }
225
226
    /**
227
     * {@inheritdoc}
228
     */
229 3
    public function setResult($result)
230
    {
231 3
        $this->result = $result;
232
233 3
        return $this;
234
    }
235
236
    /**
237
     * {@inheritdoc}
238
     */
239 2
    public function setException($exception)
240
    {
241 2
        $this->exception = $exception;
242
243 2
        return $this;
244
    }
245
}
246