public function getResourceByUri($uri)
    {
        // get rid of everything after the ?
        $uri = \strtok($uri, '?');

        $resources = $this->getResourcesAsArray($this->resources);
        foreach ($resources as $resource) {
            \assert($resource instanceof Resource);
            if ($resource->matchesUri($uri)) {
                return $resource;
            }
        }

        throw new ResourceNotFoundException($uri);
    }