code: private function buildTemplatesMap()
      {
          if (!empty($this->templatesMap)) {
              return $this->templatesMap;
          }
          
          $this->templatesMap = [];
          foreach ($this->templatesPaths as $templatesPath => $templatesNamespace) {
              if (!is_readable($templatesPath)) {
                  throw new \RuntimeException("Templates path '$templatesPath' does not exist or is not readable.");
              }
              
              foreach (glob($templatesPath . '/*.phtml') as $templatePath) {
                  $template = pathinfo($templatePath, PATHINFO_FILENAME);
                  if ($templatesNamespace !== null) {
                      $template .= '@' . $templatesNamespace;
                  }
                  if (array_key_exists($template, $this->templatesMap)) {
                      throw new \OverflowException("Can't import template '$template' from '$templatePath' as a template with the same name already exists at '{$this->templatesMap[$template]}'. You may want to use namespaces.");
                  }
                  $this->templatesMap[$template] = $templatePath;
              }
          }
          return $this->templatesMap;
      }
docs: Builds a map of template names to paths.
  
  @return array
  @throws \OverflowException|\RuntimeException