$path] = $route; $route['path'] = sprintf('%s%s', self::ROUTES_PREFIX, $path); return $route; }, $routes); return $healthRoute !== null ? [...$prefixedRoutes, $healthRoute] : $prefixedRoutes; } private static function buildUnversionedHealthRouteFromExistingRoutes(array $routes): array|null { $healthRoutes = array_filter($routes, fn (array $route) => $route['path'] === '/health'); $healthRoute = reset($healthRoutes); if ($healthRoute === false) { return null; } ['path' => $path] = $healthRoute; $healthRoute['path'] = sprintf('%s%s', self::UNVERSIONED_ROUTES_PREFIX, $path); $healthRoute['name'] = self::UNVERSIONED_HEALTH_ENDPOINT_NAME; return $healthRoute; } }