Neomerx\JsonApi\Http\Headers\MediaType::isMediaParametersEqual PHP Method

isMediaParametersEqual() private method

private isMediaParametersEqual ( Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface $mediaType ) : boolean
$mediaType Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface
return boolean
    private function isMediaParametersEqual(MediaTypeInterface $mediaType)
    {
        if ($this->bothMediaTypeParamsEmpty($mediaType) === true) {
            return true;
        } elseif ($this->bothMediaTypeParamsNotEmptyAndEqualInSize($mediaType)) {
            // Type, subtype and param name should be compared case-insensitive
            // https://tools.ietf.org/html/rfc7231#section-3.1.1.1
            $ourParameters = array_change_key_case($this->getParameters());
            $parametersToCompare = array_change_key_case($mediaType->getParameters());
            // if at least one name are different they are not equal
            if (empty(array_diff_key($ourParameters, $parametersToCompare)) === false) {
                return false;
            }
            // If we are here we have to compare values. Also some of the values should be compared case-insensitive
            // according to https://tools.ietf.org/html/rfc7231#section-3.1.1.1
            // > 'Parameter values might or might not be case-sensitive, depending on
            // the semantics of the parameter name.'
            foreach ($ourParameters as $name => $value) {
                if ($this->paramValuesEqual($name, $value, $parametersToCompare[$name]) === false) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }