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;
    }