private function mergeArguments(&$opts, $defaults) {
        if (!is_array($opts)) {
            throw new InvalidArgumentException("Argument 'opts' must be an array.");
        }
        foreach ($opts as $key => $value) {
            if (!array_key_exists($key, $defaults)) {
                throw new InvalidArgumentException("${key} is not a valid argument.");
            }
        }
        $opts += $defaults;
    }