original_string: public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object
      {
          $config = $serviceLocator->getConfig();
          $config = $config[RouterInterface::class] ?? [];
  
          $router = new Router();
          foreach ($config['routes'] ?? [] as $name => $config) {
              $router->addRoute(
                  $this->createRoute($serviceLocator, $config),
                  $name
              );
          }
  
          return $router;
      }
code: public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object
      {
          $config = $serviceLocator->getConfig();
          $config = $config[RouterInterface::class] ?? [];
  
          $router = new Router();
          foreach ($config['routes'] ?? [] as $name => $config) {
              $router->addRoute(
                  $this->createRoute($serviceLocator, $config),
                  $name
              );
          }
  
          return $router;
      }
code_tokens: public function createService ( string $ key , ServiceLocatorInterface $ serviceLocator , array $ extra = null ) : object { $ config = $ serviceLocator -> getConfig ( ) ; $ config = $ config [ RouterInterface :: class ] ?? [ ] ; $ router = new Router ( ) ; foreach ( $ config [ 'routes' ] ?? [ ] as $ name => $ config ) { $ router -> addRoute ( $ this -> createRoute ( $ serviceLocator , $ config ) , $ name ) ; } return $ router ; }
docstring: Create router.
  
  @param string                  $key
  @param ServiceLocatorInterface $serviceLocator
  @param array|null              $extra
  @return RouterInterface
  @throws ServiceLocatorException
docstring_tokens: Create router .