1 | <?php |
||
9 | class ComposerScriptRunner |
||
10 | { |
||
11 | /** @var array */ |
||
12 | protected $config = []; |
||
13 | |||
14 | /** @var Builder */ |
||
15 | protected $builder; |
||
16 | |||
17 | /** @var Event */ |
||
18 | protected $event; |
||
19 | |||
20 | /** @var string */ |
||
21 | protected $basePath; |
||
22 | |||
23 | /** |
||
24 | * ComposerScriptRunner constructor. |
||
25 | * |
||
26 | * @throws \InvalidArgumentException |
||
27 | * @param Event $event |
||
28 | * @param Builder|null $builder |
||
29 | */ |
||
30 | 22 | public function __construct(Event $event, Builder $builder = null) |
|
41 | |||
42 | /** |
||
43 | * Set a particular config value. |
||
44 | * |
||
45 | * @param string $key |
||
46 | * @param mixed $value |
||
47 | */ |
||
48 | 16 | public function set(string $key, $value) |
|
52 | |||
53 | /** |
||
54 | * Get the requested config var. |
||
55 | * |
||
56 | * @param string $key |
||
57 | * @return mixed|null |
||
58 | */ |
||
59 | 16 | public function get(string $key) |
|
63 | |||
64 | /** |
||
65 | * @return string |
||
66 | */ |
||
67 | 16 | public function getBasePath() |
|
75 | |||
76 | /** |
||
77 | * @param string $basePath |
||
78 | */ |
||
79 | 14 | public function setBasePath(string $basePath) |
|
83 | |||
84 | /** |
||
85 | * Get the full path to the env file. |
||
86 | * |
||
87 | * @return mixed|null|string |
||
88 | */ |
||
89 | 16 | public function getEnvFile() |
|
100 | |||
101 | /** |
||
102 | * @throws \InvalidArgumentException |
||
103 | */ |
||
104 | 22 | protected function populateConfig() |
|
118 | |||
119 | /** |
||
120 | * Verify that the extras a formatted properly and throw an exception if not. |
||
121 | * |
||
122 | * @throws \InvalidArgumentException |
||
123 | * @param array $extras |
||
124 | */ |
||
125 | 22 | protected function verifyExtras(array $extras) |
|
146 | |||
147 | /** |
||
148 | * @throws \InvalidArgumentException |
||
149 | */ |
||
150 | 14 | protected function createBuilder() |
|
162 | |||
163 | /** |
||
164 | * Override the Builder. |
||
165 | * |
||
166 | * @param Builder $builder |
||
167 | */ |
||
168 | 14 | public function setBuilder(Builder $builder) |
|
172 | |||
173 | /** |
||
174 | * Build the config based on a composer's package.json file. |
||
175 | * |
||
176 | * @throws \InvalidArgumentException |
||
177 | * @param Event $event |
||
178 | * @param Builder $builder |
||
179 | */ |
||
180 | 2 | public static function build(Event $event, Builder $builder = null) |
|
185 | |||
186 | /** |
||
187 | * Run the builder |
||
188 | */ |
||
189 | 12 | public function run() |
|
211 | |||
212 | /** |
||
213 | * Verify that the question has the minimum fields. |
||
214 | * |
||
215 | * @throws \InvalidArgumentException |
||
216 | * @param array $question |
||
217 | */ |
||
218 | 10 | protected function verifyQuestion(array $question) |
|
232 | } |
||
233 |