code: protected function findTemplate($text)
      {
          $matchedTemplate = [];
          $maxMatch = -1;
  
          foreach ($this->directoryIterator as $fileInfo) {
              $templateContent = file_get_contents($fileInfo->getPathname());
  
              similar_text($text, $templateContent,
                  $matchPercentage); //Compare template against text to decide on similarity percentage
  
              if ($matchPercentage > $maxMatch) {
                  $this->logger->debug(sprintf('Template "%s" is a best match for now', $fileInfo->getPathname()));
  
                  $maxMatch = $matchPercentage;
                  $matchedTemplate = [$fileInfo->getPathname() => $templateContent];
              }
          }
  
          return $matchedTemplate;
      }
docs: Iterates through the templates directory to find the closest template pattern that matches the provided text
  
  @param string $text ; The text provided by the user for parsing
  @return array; The matched template contents with its path as a key or empty array if none matched