1 | <?php |
||
22 | abstract class Base implements Command |
||
23 | { |
||
24 | /** |
||
25 | * Repository root directory. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $repositoryRoot; |
||
30 | |||
31 | /** |
||
32 | * Base constructor. |
||
33 | * |
||
34 | * @param string $root |
||
35 | */ |
||
36 | 36 | public function __construct(string $root = '') |
|
40 | |||
41 | /** |
||
42 | * Return cli command to execute. |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | 20 | public function getCommand() : string |
|
54 | |||
55 | /** |
||
56 | * Return list of acceptable exit codes. |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | 1 | public function getAcceptableExitCodes() : array |
|
64 | |||
65 | /** |
||
66 | * Do we need the -C option. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | 20 | protected function getRootOption() : string |
|
83 | |||
84 | /** |
||
85 | * Should a option be used or not. |
||
86 | * |
||
87 | * @param string $option |
||
88 | * @param bool $switch |
||
89 | * @return string |
||
90 | */ |
||
91 | 3 | protected function useOption(string $option, bool $switch) : string |
|
95 | |||
96 | |||
97 | /** |
||
98 | * Auto cast method. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 4 | public function __toString() : string |
|
106 | |||
107 | /** |
||
108 | * Return the command to execute. |
||
109 | * |
||
110 | * @return string |
||
111 | * @throws \RuntimeException |
||
112 | */ |
||
113 | protected abstract function getGitCommand() : string; |
||
114 | } |
||
115 |