private function assertValidResource($resource)
    {
        $resource = (string) $resource;
        // All resources are basic ASCII, so we can ignore the fact that `strtolower` doesn't handle UTF-8 well.
        $resource = strtolower($resource);

        if (!in_array($resource, static::VALID_RESOURCES)) {
            throw new InvalidResourceException($resource);
        }

        return $resource;
    }