Beispiel #1
0
 /**
  * @param ExposedTemplateParser $parser
  * @param ParsedTemplateInterface $parsedTemplate
  * @return Metric[]
  */
 public function count(ExposedTemplateParser $parser, ParsedTemplateInterface $parsedTemplate)
 {
     $splitTemplate = $parser->getSplitTemplate();
     $parsingState = $parser->buildObjectTree($splitTemplate);
     $objectTree = $parsingState->getRootNode()->getChildNodes();
     if (FALSE === $parsedTemplate->isCompilable()) {
         $this->get(self::METRIC_CACHED_SIZE)->setValue(0)->addMessage(new UncompilableMessage());
     } else {
         /** @var ExposedTemplateCompiler $compiler */
         $compiler = $this->objectManager->get('FluidTYPO3\\Builder\\Parser\\ExposedTemplateCompiler');
         $code = $compiler->compile($parsingState);
         $this->set(self::METRIC_CACHED_SIZE, round(mb_strlen($code) / 1024, 1));
     }
     // traversals, cumulatively increments $this->nodeCounter values.
     $this->determineTotalNodeCount($objectTree);
     $this->determineMaximumArgumentCount($objectTree);
     $this->determineMaximumNestingLevel($objectTree);
     $this->analyzePossibleSectionNodes($objectTree);
     // counting, integers which we set directly into $this->nodeCounter values.
     $this->set(self::METRIC_TOTAL_SPLITS, count($splitTemplate));
     $this->evaluate();
     return $this->metrics;
 }