src/Viserio/Component/Routing/Route/Parser.php
public static function parse(string $route, array $conditions): array
    {
        if (\strlen($route) > 1 && $route[0] !== '/') {
            throw new InvalidRoutePatternException(\sprintf(
                'Invalid route pattern: non-root route must be prefixed with \'/\', \'%s\' given.',
                $route
            ));
        }

        $segments        = [];
        $matches         = [];
        $names           = [];
        $patternSegments = \explode('/', $route);

        \array_shift($patternSegments);

        foreach ($patternSegments as $key => $patternSegment) {
            if (self::matchRouteParameters($route, $patternSegment, $conditions, $matches, $names)) {
                $segments[] = new ParameterMatcher(
                    $names,
                    self::generateRegex($matches, $conditions)
                );
            } else {
                $segments[] = new StaticMatcher($patternSegment);
            }
        }

        return $segments;
    }
public static function parse(string $route, array $conditions): array
    {
        if (\strlen($route) > 1 && $route[0] !== '/') {
            throw new InvalidRoutePatternException(\sprintf(
                'Invalid route pattern: non-root route must be prefixed with \'/\', \'%s\' given.',
                $route
            ));
        }

        $segments        = [];
        $matches         = [];
        $names           = [];
        $patternSegments = \explode('/', $route);

        \array_shift($patternSegments);

        foreach ($patternSegments as $key => $patternSegment) {
            if (self::matchRouteParameters($route, $patternSegment, $conditions, $matches, $names)) {
                $segments[] = new ParameterMatcher(
                    $names,
                    self::generateRegex($matches, $conditions)
                );
            } else {
                $segments[] = new StaticMatcher($patternSegment);
            }
        }

        return $segments;
    }
Parses the supplied route pattern into an array of route segments.

Example: '/user/{id}/create'
Should return: [
\Viserio\Component\Routing\Matcher\StaticMatcher{ $value => 'user' },
\Viserio\Component\Routing\Matcher\ParameterMatcher{ $name => 'id', $match => '[0-9]+' },
\Viserio\Component\Routing\Matcher\StaticMatcher{ $value => 'create' },
]

@param string   $route
@param string[] $conditions

@throws \Viserio\Component\Contract\Routing\Exception\InvalidArgumentException
@throws \Viserio\Component\Contract\Routing\Exception\InvalidRoutePatternException

@return array