protected function getAcceptedResourceType(string $resource, string $accept)
    {
        $available = array_keys($this->getAvailableTypes($resource));
        if (empty($available)) {
            $this->sendError(
                static::ERROR_INTERNAL_SERVER,
                "Resource '$resource' has invalid GET handlers"
            );
        }

        $accepted = static::getAcceptedType($accept, $available);
        if ($accepted === false) {
            $message = "Resource '$resource' can not generate content"
                . ' complying to Accept header';
            $this->sendError(static::ERROR_NOT_ACCEPTABLE, $message);
        }

        return $accepted;
    }