1 | <?php |
||
33 | abstract class Task |
||
1 ignored issue
–
show
|
|||
34 | { |
||
35 | /** |
||
36 | * The type of the task. |
||
37 | */ |
||
38 | const SETTING_TYPE = 'type'; |
||
39 | |||
40 | /** |
||
41 | * The id of the task. |
||
42 | */ |
||
43 | const SETTING_ID = 'id'; |
||
44 | |||
45 | /** |
||
46 | * The ISO 8601 date when the task got created. |
||
47 | */ |
||
48 | const SETTING_CREATED_AT = 'created-at'; |
||
49 | |||
50 | /** |
||
51 | * This state determines that the task is still awaiting to be executed. |
||
52 | */ |
||
53 | const STATE_PENDING = 'PENDING'; |
||
54 | |||
55 | /** |
||
56 | * This state determines that the task is still running. |
||
57 | */ |
||
58 | const STATE_RUNNING = 'RUNNING'; |
||
59 | |||
60 | /** |
||
61 | * This state determines that the task has been finished. |
||
62 | */ |
||
63 | const STATE_FINISHED = 'FINISHED'; |
||
64 | |||
65 | /** |
||
66 | * This state determines that the task has been finished with errors. |
||
67 | */ |
||
68 | const STATE_ERROR = 'ERROR'; |
||
69 | |||
70 | /** |
||
71 | * The task file to write to. |
||
72 | * |
||
73 | * @var JsonArray |
||
74 | */ |
||
75 | protected $file; |
||
76 | |||
77 | /** |
||
78 | * The log file to write to. |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $logFile; |
||
83 | |||
84 | /** |
||
85 | * The input/output handler. |
||
86 | * |
||
87 | * @var IOInterface |
||
88 | */ |
||
89 | private $inputOutput; |
||
90 | |||
91 | /** |
||
92 | * Task constructor. |
||
93 | * |
||
94 | * @param JsonArray $file The json file to write to. |
||
95 | */ |
||
96 | public function __construct(JsonArray $file) |
||
104 | |||
105 | /** |
||
106 | * Retrieve the task id. |
||
107 | * |
||
108 | * @return string |
||
1 ignored issue
–
show
|
|||
109 | */ |
||
110 | public function getId() |
||
114 | |||
115 | /** |
||
116 | * Retrieve the current output. |
||
117 | * |
||
118 | * @param null|int $offset The offset in bytes to read from. |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getOutput($offset = null) |
||
130 | |||
131 | /** |
||
132 | * Retrieve the task type name. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | abstract public function getType(); |
||
137 | |||
138 | /** |
||
139 | * Perform the task. |
||
140 | * |
||
141 | * @param string $logFile The log file to write to. |
||
142 | * |
||
143 | * @return void |
||
144 | * |
||
145 | * @throws \LogicException When the task has already been run. |
||
146 | * |
||
147 | * @throws \RuntimeException When the execution. failed. |
||
148 | */ |
||
149 | public function perform($logFile) |
||
192 | |||
193 | /** |
||
194 | * Perform the task. |
||
195 | * |
||
196 | * @return void |
||
197 | */ |
||
198 | abstract public function doPerform(); |
||
199 | |||
200 | /** |
||
201 | * Add some output. |
||
202 | * |
||
203 | * @param string $string The output string to append to the output. |
||
204 | * |
||
205 | * @return void |
||
206 | * |
||
207 | * @throws \LogicException When called prior to perform(). |
||
208 | */ |
||
209 | public function addOutput($string) |
||
217 | |||
218 | /** |
||
219 | * Retrieve the IO interface. |
||
220 | * |
||
221 | * @return IOInterface |
||
222 | */ |
||
223 | public function getIO() |
||
231 | |||
232 | /** |
||
233 | * Retrieve the current status of a task. |
||
234 | * |
||
235 | * @return string |
||
1 ignored issue
–
show
|
|||
236 | */ |
||
237 | public function getStatus() |
||
241 | |||
242 | /** |
||
243 | * Retrieve when this task got created as ISO 8601 date string. |
||
244 | * |
||
245 | * @return \DateTime |
||
246 | */ |
||
247 | public function getCreatedAt() |
||
251 | |||
252 | /** |
||
253 | * Remove the attached files for this task from disk. |
||
254 | * |
||
255 | * @return void |
||
256 | */ |
||
257 | public function removeAssets() |
||
268 | |||
269 | /** |
||
270 | * Set the task state. |
||
271 | * |
||
272 | * @param string $status The status code. |
||
273 | * |
||
274 | * @return void |
||
275 | */ |
||
276 | protected function setStatus($status) |
||
280 | |||
281 | /** |
||
282 | * Retrieve the Input handler. |
||
283 | * |
||
284 | * @return InputInterface |
||
285 | */ |
||
286 | private function getInput() |
||
294 | } |
||
295 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.