makeRoute(), range(1, 1000)))); enum RoutePart: string { case PARAMS = 'params'; case ENDPOINT = 'endpoint'; case MIDPOINT = 'midpoint'; public function matches(array $params, array $endpoint, array $midpoint): string { return '/' . match ($this) { self::PARAMS => ':' . $params[array_rand($params)], self::ENDPOINT => $endpoint[array_rand($endpoint)], self::MIDPOINT => $midpoint[array_rand($midpoint)], }; } } function makeRoute(): string { global $methods, $apis, $params, $endpoint, $midpoint; return $methods[array_rand($methods)] . ' /' . $apis[array_rand($apis)] . implode('', array_map(fn($option) => $option->matches($params, $endpoint, $midpoint), array_rand(array_flip(RoutePart::cases()), rand(1, 8)))); }