public static function createFromReflection(\ReflectionMethod $reflectionMethod, string $basePath = '')
    {
        $routes = [];

        if (is_a($reflectionMethod->class, '\Berlioz\Core\Controller\Controller', true)) {
            try {
                if ($reflectionMethod->isPublic()) {
                    if ($methodDoc = $reflectionMethod->getDocComment()) {
                        $docBlock = Router::getDocBlockFactory()->create($methodDoc);

                        if ($docBlock->hasTag('route')) {
                            /** @var \phpDocumentor\Reflection\DocBlock\Tags\Generic $tag */
                            foreach ($docBlock->getTagsByName('route') as $tag) {
                                $route = new Route;
                                $route->setRouteDeclaration($tag->getDescription()->render(), $basePath);
                                $route->setSummary($docBlock->getSummary());
                                $route->setDescription($docBlock->getDescription()->render());
                                $route->setInvoke($reflectionMethod->class, $reflectionMethod->getName());
                                $route->getRouteRegex();

                                $routes[] = $route;
                            }
                        }
                    }
                } else {
                    /** @var \ReflectionMethod $reflectionMethod */
                    throw new BerliozException('Must be public');
                }
            } catch (BerliozException $e) {
                /** @var \ReflectionMethod $reflectionMethod */
                throw new BerliozException(sprintf('Method "%s::%s" route error: %s', $reflectionMethod->class, $reflectionMethod->getName(), $e->getMessage()));
            }
        } else {
            throw new BerliozException(sprintf('Class "%s" must be a sub class of "\Berlioz\Core\Controller\Controller"', $reflectionMethod->class));
        }

        return $routes;
    }
public static function createFromReflection(\ReflectionMethod $reflectionMethod, string $basePath = '')
    {
        $routes = [];

        if (is_a($reflectionMethod->class, '\Berlioz\Core\Controller\Controller', true)) {
            try {
                if ($reflectionMethod->isPublic()) {
                    if ($methodDoc = $reflectionMethod->getDocComment()) {
                        $docBlock = Router::getDocBlockFactory()->create($methodDoc);

                        if ($docBlock->hasTag('route')) {
                            /** @var \phpDocumentor\Reflection\DocBlock\Tags\Generic $tag */
                            foreach ($docBlock->getTagsByName('route') as $tag) {
                                $route = new Route;
                                $route->setRouteDeclaration($tag->getDescription()->render(), $basePath);
                                $route->setSummary($docBlock->getSummary());
                                $route->setDescription($docBlock->getDescription()->render());
                                $route->setInvoke($reflectionMethod->class, $reflectionMethod->getName());
                                $route->getRouteRegex();

                                $routes[] = $route;
                            }
                        }
                    }
                } else {
                    /** @var \ReflectionMethod $reflectionMethod */
                    throw new BerliozException('Must be public');
                }
            } catch (BerliozException $e) {
                /** @var \ReflectionMethod $reflectionMethod */
                throw new BerliozException(sprintf('Method "%s::%s" route error: %s', $reflectionMethod->class, $reflectionMethod->getName(), $e->getMessage()));
            }
        } else {
            throw new BerliozException(sprintf('Class "%s" must be a sub class of "\Berlioz\Core\Controller\Controller"', $reflectionMethod->class));
        }

        return $routes;
    }
public static function createFromReflection ( \ ReflectionMethod $ reflectionMethod , string $ basePath = '' ) { $ routes = [ ] ; if ( is_a ( $ reflectionMethod -> class , '\Berlioz\Core\Controller\Controller' , true ) ) { try { if ( $ reflectionMethod -> isPublic ( ) ) { if ( $ methodDoc = $ reflectionMethod -> getDocComment ( ) ) { $ docBlock = Router :: getDocBlockFactory ( ) -> create ( $ methodDoc ) ; if ( $ docBlock -> hasTag ( 'route' ) ) { /** @var \phpDocumentor\Reflection\DocBlock\Tags\Generic $tag */ foreach ( $ docBlock -> getTagsByName ( 'route' ) as $ tag ) { $ route = new Route ; $ route -> setRouteDeclaration ( $ tag -> getDescription ( ) -> render ( ) , $ basePath ) ; $ route -> setSummary ( $ docBlock -> getSummary ( ) ) ; $ route -> setDescription ( $ docBlock -> getDescription ( ) -> render ( ) ) ; $ route -> setInvoke ( $ reflectionMethod -> class , $ reflectionMethod -> getName ( ) ) ; $ route -> getRouteRegex ( ) ; $ routes [ ] = $ route ; } } } } else { /** @var \ReflectionMethod $reflectionMethod */ throw new BerliozException ( 'Must be public' ) ; } } catch ( BerliozException $ e ) { /** @var \ReflectionMethod $reflectionMethod */ throw new BerliozException ( sprintf ( 'Method "%s::%s" route error: %s' , $ reflectionMethod -> class , $ reflectionMethod -> getName ( ) , $ e -> getMessage ( ) ) ) ; } } else { throw new BerliozException ( sprintf ( 'Class "%s" must be a sub class of "\Berlioz\Core\Controller\Controller"' , $ reflectionMethod -> class ) ) ; } return $ routes ; }
Create Route from \ReflectionMethod object.

@param \ReflectionMethod $reflectionMethod Reflection of method
@param string            $basePath         Base of path for all routes in method

@return Route[]
@throws \Berlioz\Core\Exception\BerliozException
Create Route from \ ReflectionMethod object .