Disque\Command\BaseCommand::toArguments PHP Method

toArguments() protected method

Client-supplied options are amended with the default options defined in $this->options. Options whose value is set to null or false are ignored
protected toArguments ( array $options ) : array
$options array Command options
return array Command arguments
    protected function toArguments(array $options)
    {
        if (empty($options)) {
            return [];
        } elseif (!empty(array_diff_key($options, $this->availableArguments))) {
            throw new InvalidOptionException($this, $options);
        }
        // Pad, don't overwrite, the client provided options with the default ones
        $options += $this->options;
        $arguments = [];
        foreach ($this->availableArguments as $option => $argument) {
            if (!isset($options[$option]) || $options[$option] === false) {
                continue;
            }
            $value = $options[$option];
            if (is_array($value)) {
                foreach ($value as $currentValue) {
                    $arguments[] = $argument;
                    $arguments[] = $currentValue;
                }
            } else {
                $arguments[] = $argument;
                if (!is_bool($value)) {
                    $arguments[] = $value;
                }
            }
        }
        return $arguments;
    }