1 | <?php |
||
19 | abstract class Cli |
||
20 | { |
||
21 | /** |
||
22 | * Command runner to execute the executable. |
||
23 | * |
||
24 | * @var \SebastianFeldmann\Cli\Command\Runner |
||
25 | */ |
||
26 | protected $runner; |
||
27 | |||
28 | /** |
||
29 | * Executable command. |
||
30 | * |
||
31 | 26 | * @var \phpbu\App\Cli\Executable |
|
32 | */ |
||
33 | 26 | protected $executable; |
|
34 | 26 | ||
35 | /** |
||
36 | * Cli constructor. |
||
37 | * |
||
38 | * @param \SebastianFeldmann\Cli\Command\Runner $runner |
||
39 | */ |
||
40 | public function __construct(Runner $runner = null) |
||
44 | |||
45 | 23 | /** |
|
46 | * Executes the cli commands and handles compression |
||
47 | * |
||
48 | * @param \phpbu\App\Backup\Target $target |
||
49 | * @return \phpbu\App\Cli\Result |
||
50 | * @throws \RuntimeException |
||
51 | */ |
||
52 | protected function execute(Target $target) : Result |
||
56 | |||
57 | /** |
||
58 | * Execute a cli command. |
||
59 | * |
||
60 | * @param \phpbu\App\Cli\Executable $command |
||
61 | * @return \phpbu\App\Cli\Result |
||
62 | */ |
||
63 | protected function runCommand(Executable $command) : Result |
||
74 | |||
75 | /** |
||
76 | * Remove file if it exists. |
||
77 | * |
||
78 | * @param string $file |
||
79 | */ |
||
80 | public function unlinkErrorFile(string $file) |
||
86 | |||
87 | /** |
||
88 | * Returns the executable for this action. |
||
89 | * |
||
90 | * @param \phpbu\App\Backup\Target $target |
||
91 | * @return \phpbu\App\Cli\Executable |
||
92 | */ |
||
93 | public function getExecutable(Target $target) : Executable |
||
100 | |||
101 | /** |
||
102 | * Creates the executable for this action. |
||
103 | * |
||
104 | * @param \phpbu\App\Backup\Target $target |
||
105 | * @return \phpbu\App\Cli\Executable |
||
106 | */ |
||
107 | abstract protected function createExecutable(Target $target) : Executable; |
||
108 | } |
||
109 |