public function decomposeURI($uri, &$type = null)
    {
        $elements = [];

        if (!self::URIIsCandidate($uri)) {
            return $elements;
        }

        foreach ($this->getURIPatterns() as $name => $pattern) {
            if (preg_match($pattern, $uri, $matches)) {
                $type = $name;
                $elements = [
                    'type'  => $matches['type'],
                    'id'    => $matches['id'],
                ];
                break;
            }
        }

        return $elements;
    }