Gush\Helper\ProcessHelper::parseProcessArguments PHP Method

parseProcessArguments() protected method

protected parseProcessArguments ( string $command ) : string[]
$command string
return string[]
    protected function parseProcessArguments($command)
    {
        if (preg_match_all('/((?:"(?:(?:[^"\\\\]|\\\\.)+)")|(?:\'(?:[^\'\\\\]|\\\\.)+\')|[^ ]+)/i', $command, $args)) {
            $normalizeCommandArgument = function ($argument) {
                if ("'" === $argument[0] || '"' === $argument[0]) {
                    $quote = $argument[0];
                    $argument = substr($argument, 1, -1);
                    $argument = str_replace('\\' . $quote, $quote, $argument);
                    $argument = str_replace('\\\\', '\\', $argument);
                }
                return $argument;
            };
            return array_map($normalizeCommandArgument, $args[0]);
        }
        throw new \InvalidArgumentException(sprintf('Unable to parse command "%s".', $command));
    }