1 | <?php |
||
5 | abstract class Command |
||
6 | { |
||
7 | /** |
||
8 | * @var OptionsInterface |
||
9 | */ |
||
10 | private $options; |
||
11 | |||
12 | /** |
||
13 | * Execute the command using the current options. |
||
14 | * |
||
15 | * @return mixed |
||
16 | */ |
||
17 | abstract public function execute(); |
||
18 | |||
19 | /** |
||
20 | * Allow usage as a callable. |
||
21 | * |
||
22 | * @see Command::execute() |
||
23 | * |
||
24 | * @return mixed |
||
25 | */ |
||
26 | 1 | final public function __invoke() |
|
30 | |||
31 | /** |
||
32 | * Get the currently defined options. |
||
33 | * |
||
34 | * @return OptionsInterface |
||
35 | * |
||
36 | * @throws CommandException |
||
37 | * If no options have been added to the command. |
||
38 | */ |
||
39 | 2 | final public function options() |
|
47 | |||
48 | /** |
||
49 | * Get a copy with new options. |
||
50 | * |
||
51 | * @param OptionsInterface $options |
||
52 | * |
||
53 | * @return static |
||
54 | */ |
||
55 | 1 | final public function withOptions(OptionsInterface $options) |
|
62 | } |
||
63 |