private static function extractAttributesFromSegment($url, $path, $i, $j, $segment, &$attributes)
    {
        // Required parameters
        if (preg_match('/{[\w]+}/', $segment)) {
            $attributeName              = preg_replace(['/{/', '/\?/', '/}/'], '', $segment);
            $attributes[$attributeName] = $url[$i];
        }

        // Optional parameter
        if (
            preg_match('/{[\w]+\?}/', $segment) &&
            ( ! isset($path[$j + 1]) || $path[$j + 1] !== $url[$i])
        ) {
            $attributeName              = preg_replace(['/{/', '/\?/', '/}/'], '', $segment);
            $attributes[$attributeName] = $url[$i];
        }
    }