protected function validateAllowedParameters(array $allowed, $params, $paramName)
    {
        if (!is_array($params)) {
            $params = array($params);
        }

        foreach ($params as $param) {
            if (!in_array($param, $allowed)) {
                throw new InvalidArgumentException(sprintf(
                    'The "%s" parameter may contain only values within "%s". "%s" given.',
                    $paramName,
                    implode(", ", $allowed),
                    $param
                ));
            }
        }

        return $params;
    }