PHPDaemon\Core\ShellCommand::buildArgs PHP Method

buildArgs() public static method

Build arguments string from associative/enumerated array (may be mixed)
public static buildArgs ( array $args ) : string
$args array
return string
    public static function buildArgs($args)
    {
        if (!is_array($args)) {
            return '';
        }
        $ret = '';
        foreach ($args as $k => $v) {
            if (!is_int($v) && $v !== null) {
                $v = escapeshellarg($v);
            }
            if (is_int($k)) {
                $ret .= ' ' . $v;
            } else {
                if ($k[0] !== '-') {
                    $ret .= ' --' . $k . ($v !== null ? '=' . $v : '');
                } else {
                    $ret .= ' ' . $k . ($v !== null ? '=' . $v : '');
                }
            }
        }
        return $ret;
    }