Total Complexity | 7 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class InvalidTask extends AbstractTask |
||
10 | { |
||
11 | /** |
||
12 | * The invalid task class. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $class; |
||
17 | |||
18 | /** |
||
19 | * Construct the class |
||
20 | * |
||
21 | * @param string $class |
||
22 | */ |
||
23 | public function __construct(string $class) |
||
24 | { |
||
25 | $this->class = $class; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Run the task |
||
30 | * |
||
31 | * @return mixed |
||
32 | */ |
||
33 | public function run() |
||
34 | { |
||
35 | return false; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Set the invalid task class |
||
40 | * |
||
41 | * @param string $class |
||
42 | * @return self |
||
43 | */ |
||
44 | public function getClass(): string |
||
45 | { |
||
46 | return $this->class; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Retrieve this task purpose |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getPurpose(): string |
||
55 | { |
||
56 | return class_basename($this->class); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Retrieve the error that caused this task to fail |
||
61 | * |
||
62 | * @return string|null |
||
63 | */ |
||
64 | public function getError(): ?string |
||
65 | { |
||
66 | if ($e = $this->getException()) { |
||
67 | return $e->getMessage(); |
||
68 | } |
||
69 | |||
70 | return "The item [{$this->class}] is not a valid task"; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Determine whether this task should rollback if the given task fails |
||
75 | * |
||
76 | * @param AbstractTask|null $task |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function shouldRollbackDueTo(?AbstractTask $task): bool |
||
82 | } |
||
83 | } |
||
84 |