1 | <?php |
||
26 | class Configurator extends Runner |
||
27 | { |
||
28 | /** |
||
29 | * Force mode |
||
30 | * |
||
31 | * @var bool |
||
32 | */ |
||
33 | private $force; |
||
34 | |||
35 | /** |
||
36 | * Extend existing config or create new one |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | private $mode; |
||
41 | |||
42 | /** |
||
43 | * Execute the configurator. |
||
44 | */ |
||
45 | 4 | public function run() |
|
60 | |||
61 | /** |
||
62 | * Force mode setter. |
||
63 | * |
||
64 | * @param bool $force |
||
65 | * @return \SebastianFeldmann\CaptainHook\Runner\Configurator |
||
66 | */ |
||
67 | 2 | public function force(bool $force) : Configurator |
|
72 | |||
73 | /** |
||
74 | * Set configuration mode. |
||
75 | * |
||
76 | * @param bool $extend |
||
77 | * @return \SebastianFeldmann\CaptainHook\Runner\Configurator |
||
78 | */ |
||
79 | 3 | public function extend(bool $extend) : Configurator |
|
84 | |||
85 | /** |
||
86 | * Return config to handle. |
||
87 | * |
||
88 | * @return \SebastianFeldmann\CaptainHook\Config |
||
89 | */ |
||
90 | 4 | public function getConfigToManipulate() : Config |
|
100 | |||
101 | /** |
||
102 | * Make sure force mode is set if config file exists. |
||
103 | * |
||
104 | * @throws \RuntimeException |
||
105 | */ |
||
106 | 2 | private function ensureForce() |
|
112 | |||
113 | /** |
||
114 | * Configure a hook. |
||
115 | * |
||
116 | * @param \SebastianFeldmann\CaptainHook\Config $config |
||
117 | * @param string $hook |
||
118 | */ |
||
119 | 5 | public function configureHook(Config $config, string $hook) |
|
141 | |||
142 | /** |
||
143 | * Setup a action config with user input. |
||
144 | * |
||
145 | * @return \SebastianFeldmann\CaptainHook\Config\Action |
||
146 | */ |
||
147 | 3 | public function getActionConfig() : Config\Action |
|
155 | |||
156 | /** |
||
157 | * Ask the user for any action options. |
||
158 | * |
||
159 | * @param string $type |
||
160 | * @return array |
||
161 | */ |
||
162 | 3 | public function getActionOptions(string $type) : array |
|
166 | |||
167 | /** |
||
168 | * Get the php action options. |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | 2 | protected function getPHPActionOptions() : array |
|
183 | |||
184 | /** |
||
185 | * Ask the user for a php action option. |
||
186 | * |
||
187 | * @return array |
||
188 | */ |
||
189 | 2 | protected function getPHPActionOption() : array |
|
204 | |||
205 | /** |
||
206 | * Write config to project root. |
||
207 | * |
||
208 | * @param \SebastianFeldmann\CaptainHook\Config $config |
||
209 | */ |
||
210 | 3 | public function writeConfig(Config $config) |
|
216 | |||
217 | /** |
||
218 | * PHP action option validation. |
||
219 | * |
||
220 | * @param $option |
||
221 | * @return string |
||
222 | * @throws \Exception |
||
223 | */ |
||
224 | 2 | public static function isPHPActionOptionValid(string $option) : string |
|
231 | } |
||
232 |