1 | <?php |
||
11 | class ComposerScriptRunner |
||
12 | { |
||
13 | /** @var array */ |
||
14 | protected $config = []; |
||
15 | |||
16 | /** @var Builder */ |
||
17 | protected $builder; |
||
18 | |||
19 | /** @var Event */ |
||
20 | protected $event; |
||
21 | |||
22 | /** @var string */ |
||
23 | protected $basePath; |
||
24 | |||
25 | /** |
||
26 | * ComposerScriptRunner constructor. |
||
27 | * |
||
28 | * @throws ConfigurationException |
||
29 | * @param Event $event |
||
30 | * @param Builder|null $builder |
||
31 | */ |
||
32 | 22 | public function __construct(Event $event, Builder $builder = null) |
|
43 | |||
44 | /** |
||
45 | * Set a particular config value. |
||
46 | * |
||
47 | * @param string $key |
||
48 | * @param mixed $value |
||
49 | */ |
||
50 | 16 | public function set(string $key, $value) |
|
54 | |||
55 | /** |
||
56 | * Get the requested config var. |
||
57 | * |
||
58 | * @param string $key |
||
59 | * @return mixed|null |
||
60 | */ |
||
61 | 16 | public function get(string $key) |
|
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | 16 | public function getBasePath() |
|
77 | |||
78 | /** |
||
79 | * @param string $basePath |
||
80 | */ |
||
81 | 14 | public function setBasePath(string $basePath) |
|
85 | |||
86 | /** |
||
87 | * Get the full path to the env file. |
||
88 | * |
||
89 | * @return mixed|null|string |
||
90 | */ |
||
91 | 16 | public function getEnvFile() |
|
102 | |||
103 | /** |
||
104 | * @throws \InvalidArgumentException |
||
105 | */ |
||
106 | 22 | protected function populateConfig() |
|
120 | |||
121 | /** |
||
122 | * Verify that the extras a formatted properly and throw an exception if not. |
||
123 | * |
||
124 | * @throws \InvalidArgumentException |
||
125 | * @param array $extras |
||
126 | */ |
||
127 | 22 | protected function verifyExtras(array $extras) |
|
148 | |||
149 | /** |
||
150 | * @throws ConfigurationException |
||
151 | */ |
||
152 | 14 | protected function createBuilder() |
|
164 | |||
165 | /** |
||
166 | * Override the Builder. |
||
167 | * |
||
168 | * @param Builder $builder |
||
169 | */ |
||
170 | 14 | public function setBuilder(Builder $builder) |
|
174 | |||
175 | /** |
||
176 | * Build the config based on a composer's package.json file. |
||
177 | * |
||
178 | * @throws ConfigurationException |
||
179 | * @throws AskException |
||
180 | * @param Event $event |
||
181 | * @param Builder $builder |
||
182 | */ |
||
183 | 2 | public static function build(Event $event, Builder $builder = null) |
|
188 | |||
189 | /** |
||
190 | * Run the builder |
||
191 | * |
||
192 | * @throws AskException |
||
193 | */ |
||
194 | 12 | public function run() |
|
205 | |||
206 | /** |
||
207 | * Run through each of the questions and ask each one. |
||
208 | * |
||
209 | * @param array $questons |
||
210 | */ |
||
211 | 10 | protected function askQuestions(array $questons) |
|
224 | |||
225 | /** |
||
226 | * Verify that the question has the minimum fields. |
||
227 | * |
||
228 | * @throws \InvalidArgumentException |
||
229 | * @param array $question |
||
230 | */ |
||
231 | 10 | protected function verifyQuestion(array $question) |
|
245 | |||
246 | /** |
||
247 | * If we're clobbering and we're not supposed to, should we cancel? |
||
248 | * |
||
249 | * @return bool |
||
250 | */ |
||
251 | 12 | protected function shouldCancelOnClobber() |
|
261 | } |
||
262 |