*/ private array $routes = []; private array $controllers = []; public function add(string $controllerClass): self { $this->controllers[] = $controllerClass; $reflectionClass = new ReflectionClass($controllerClass); foreach ($reflectionClass->getMethods() as $method) { $attributes = $method->getAttributes(Route::class, ReflectionAttribute::IS_INSTANCEOF); if (count($attributes) === 0) { continue; } $route = $attributes[0]->newInstance(); $this->routes[] = new RouteConfig( $route, $controllerClass, $method->getName(), ); } return $this; } /** * @return array */ public function getRoutes(): array { return $this->routes; } public function getControllers(): array { return $this->controllers; } }