@@ -199,22 +199,44 @@ public function exec($command, array $parameters = [])
199
199
protected function compileParameters (array $ parameters )
200
200
{
201
201
return collect ($ parameters )->map (function ($ value , $ key ) {
202
- if (is_array ($ value ) && Str::startsWith ($ key , '-- ' )) {
203
- return collect ($ value )->map (function ($ value ) use ($ key ) {
204
- return $ key .'= ' .ProcessUtils::escapeArgument ($ value );
205
- })->implode (' ' );
206
- } elseif (is_array ($ value )) {
207
- $ value = collect ($ value )->map (function ($ value ) {
208
- return ProcessUtils::escapeArgument ($ value );
209
- })->implode (' ' );
210
- } elseif (! is_numeric ($ value ) && ! preg_match ('/^(-.$|--.*)/i ' , $ value )) {
202
+ if (is_array ($ value )) {
203
+ return $ this ->compileArrayInput ($ key , $ value );
204
+ }
205
+
206
+ if (! is_numeric ($ value ) && ! preg_match ('/^(-.$|--.*)/i ' , $ value )) {
211
207
$ value = ProcessUtils::escapeArgument ($ value );
212
208
}
213
209
214
210
return is_numeric ($ key ) ? $ value : "{$ key }= {$ value }" ;
215
211
})->implode (' ' );
216
212
}
217
213
214
+ /**
215
+ * Compile array input for a command.
216
+ *
217
+ * @param string|int $key
218
+ * @param array $value
219
+ * @return string
220
+ */
221
+ public function compileArrayInput ($ key , $ value )
222
+ {
223
+ $ value = collect ($ value )->map (function ($ value ) {
224
+ return ProcessUtils::escapeArgument ($ value );
225
+ });
226
+
227
+ if (Str::startsWith ($ key , '-- ' )) {
228
+ $ value = $ value ->map (function ($ value ) use ($ key ) {
229
+ return "{$ key }= {$ value }" ;
230
+ });
231
+ } elseif (Str::startsWith ($ key , '- ' )) {
232
+ $ value = $ value ->map (function ($ value ) use ($ key ) {
233
+ return "{$ key } {$ value }" ;
234
+ });
235
+ }
236
+
237
+ return $ value ->implode (' ' );
238
+ }
239
+
218
240
/**
219
241
* Determine if the server is allowed to run this event.
220
242
*
0 commit comments