| 1 | <?php |
||
| 20 | abstract class AbstractTask |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var array Task custom options |
||
| 24 | */ |
||
| 25 | protected $options = []; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var Runtime |
||
| 29 | */ |
||
| 30 | protected $runtime; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Get the Name/Code of the Task |
||
| 34 | * |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | abstract public function getName(); |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Get a short Description of the Task |
||
| 41 | * |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | abstract public function getDescription(); |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Executes the Command |
||
| 48 | * |
||
| 49 | * @return bool |
||
| 50 | */ |
||
| 51 | abstract public function execute(); |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Set additional Options for the Task |
||
| 55 | * |
||
| 56 | * @param array $options Options |
||
| 57 | * @return AbstractTask |
||
| 58 | */ |
||
| 59 | public function setOptions($options = []) |
||
| 60 | { |
||
| 61 | if (!is_array($options)) { |
||
| 62 | $options = []; |
||
| 63 | } |
||
| 64 | |||
| 65 | $this->options = array_merge($this->getDefaults(), $options); |
||
| 66 | return $this; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Set the Runtime instance |
||
| 71 | * |
||
| 72 | * @param Runtime $runtime |
||
| 73 | * @return AbstractTask |
||
| 74 | */ |
||
| 75 | public function setRuntime(Runtime $runtime) |
||
| 76 | { |
||
| 77 | $this->runtime = $runtime; |
||
| 78 | return $this; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Return Default options |
||
| 83 | * @return array |
||
| 84 | */ |
||
| 85 | public function getDefaults() |
||
| 89 | } |
||
| 90 |