Arcanedev\Localization\Utilities\Url::extractAttributesFromSegment PHP Method

extractAttributesFromSegment() private static method

Extract attribute from a segment.
private static extractAttributesFromSegment ( array $url, array $path, integer $i, integer $j, string $segment, array &$attributes )
$url array
$path array
$i integer
$j integer
$segment string
$attributes array
    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];
        }
    }