1 | <?php |
||
52 | abstract class AbstractCommand |
||
53 | { |
||
54 | /** @var string $name */ |
||
55 | protected $name = ''; |
||
56 | |||
57 | /** @var string $hgPath */ |
||
58 | protected $hgPath = 'hg'; |
||
59 | |||
60 | /** @var string $command */ |
||
61 | protected $command = '%s %s'; |
||
62 | |||
63 | /** |
||
64 | * Command specific options. |
||
65 | * |
||
66 | * @var array $options |
||
67 | */ |
||
68 | protected $options = []; |
||
69 | |||
70 | /** @var array $globalOptions */ |
||
71 | protected $globalOptions = [ |
||
72 | '--repository' => '', |
||
73 | '--cwd' => '', |
||
74 | '--noninteractive' => false, |
||
75 | '--quiet' => false, |
||
76 | '--verbose' => false, |
||
77 | '--config' => [], |
||
78 | '--debug' => false, |
||
79 | '--debugger' => false, |
||
80 | '--encoding' => '', |
||
81 | '--encodingmode' => '', |
||
82 | '--traceback' => false, |
||
83 | '--time' => false, |
||
84 | '--profile' => false, |
||
85 | '--version' => false, |
||
86 | '--help' => false, |
||
87 | '--hidden' => false, |
||
88 | ]; |
||
89 | |||
90 | /** |
||
91 | * Get hg path. |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | 1 | public function getHgPath() |
|
99 | |||
100 | /** |
||
101 | * Set path to hg executable. |
||
102 | * |
||
103 | * @param string $path |
||
104 | * |
||
105 | * @return $this |
||
106 | */ |
||
107 | 1 | public function setHgPath($path) |
|
113 | |||
114 | /** |
||
115 | * Returns a string representation for the mercurial shell command. |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | 44 | public function __toString() |
|
123 | |||
124 | /** |
||
125 | * Standard constructor. |
||
126 | * |
||
127 | * - sets the concrete commands name |
||
128 | * - merges the global options with the concrete commands options |
||
129 | * |
||
130 | * @param mixed $options |
||
131 | */ |
||
132 | 51 | public function __construct($options = []) |
|
138 | |||
139 | /** |
||
140 | * Execute mercurial command. |
||
141 | * |
||
142 | * @return string |
||
143 | * |
||
144 | * @throws \RuntimeException |
||
145 | */ |
||
146 | 2 | public function execute() |
|
163 | |||
164 | /** |
||
165 | * Returns the string representation of the command. |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | 44 | public function asString() |
|
173 | |||
174 | /** |
||
175 | * Magic method to get option entries with a getter/setter method. |
||
176 | * |
||
177 | * @param string $name |
||
178 | * @param array $arguments |
||
179 | * |
||
180 | * @return boolean|array|string|self |
||
181 | * |
||
182 | * @throws \InvalidArgumentException |
||
183 | */ |
||
184 | 43 | public function __call($name, $arguments) |
|
215 | |||
216 | /** |
||
217 | * Does property exist check. |
||
218 | * |
||
219 | * @param string $property |
||
220 | * |
||
221 | * @throws \InvalidArgumentException |
||
222 | */ |
||
223 | 42 | private function doesPropertyExist($property) |
|
229 | |||
230 | /** |
||
231 | * Concatinates string options. |
||
232 | * |
||
233 | * @return string |
||
234 | */ |
||
235 | 41 | protected function assembleOptionString() |
|
251 | |||
252 | /** |
||
253 | * Returns the concrete commands name. |
||
254 | * |
||
255 | * @return string |
||
256 | */ |
||
257 | 51 | private function getCommandName() |
|
264 | } |
||
265 |