1 | <?php |
||
18 | abstract class Abstraction |
||
19 | { |
||
20 | /** |
||
21 | * Command name. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $cmd; |
||
26 | |||
27 | /** |
||
28 | * List of acceptable exit codes. |
||
29 | * |
||
30 | * @var int[] |
||
31 | */ |
||
32 | protected $acceptableExitCodes = [0]; |
||
33 | |||
34 | /** |
||
35 | * Absolute path to command. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $binary; |
||
40 | |||
41 | /** |
||
42 | * Command to execute |
||
43 | * |
||
44 | * @var \SebastianFeldmann\Cli\CommandLine |
||
45 | */ |
||
46 | protected $commandLine; |
||
47 | |||
48 | /** |
||
49 | * Setup binary. |
||
50 | * |
||
51 | * @param string $cmd |
||
52 | * @param string $path |
||
53 | */ |
||
54 | 214 | protected function setup(string $cmd, string $path = '') { |
|
58 | |||
59 | /** |
||
60 | * Returns the CommandLine for this command. |
||
61 | * |
||
62 | * @return \SebastianFeldmann\Cli\CommandLine |
||
63 | */ |
||
64 | 204 | public function getCommandLine() : CommandLine |
|
68 | |||
69 | /** |
||
70 | * CommandLine generator. |
||
71 | * |
||
72 | * @return \SebastianFeldmann\Cli\CommandLine |
||
73 | */ |
||
74 | abstract protected function createCommandLine() : CommandLine; |
||
75 | |||
76 | /** |
||
77 | * Return the command line to execute. |
||
78 | * |
||
79 | * @return string |
||
80 | * @throws \phpbu\App\Exception |
||
81 | */ |
||
82 | 189 | public function getCommand() : string |
|
86 | |||
87 | /** |
||
88 | * Returns a lost of acceptable exit codes. |
||
89 | * |
||
90 | * @return array |
||
91 | */ |
||
92 | 7 | public function getAcceptableExitCodes() : array |
|
96 | |||
97 | /** |
||
98 | * Return the command with masked passwords or keys. |
||
99 | * |
||
100 | * By default just return the original command. Subclasses with password |
||
101 | * arguments have to override this method. |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | 11 | public function getCommandPrintable() : string |
|
109 | } |
||
110 |