src/NodeVisitors/MetricChecker.php
/**
     * Determines if this node and it's children are of a complexity that could
     * use some clarification based on Cyclomatic Complexity.
     */
Determines if this node and it's children are of a complexity that could
use some clarification based on Cyclomatic Complexity.
Determines if this node and it ' s children are of a complexity that could use some clarification based on Cyclomatic Complexity .
public function leaveNode(\PhpParser\Node $node)
    {
        if (is_a($node, "\PhpParser\Node\FunctionLike")) {
            $metricValue = $this->metric->getValue($node);
            $name = 'Anonymous function';
            if (\property_exists($node, 'name')) {
                $parent = $node->getAttribute('parent');
                if (!empty($parent) && \property_exists($parent, 'namespacedName')) {
                    $name = $parent->namespacedName . '::';
                    $name .= $node->name . '()';
                }
                if (\property_exists($node, 'namespacedName')) {
                    $name = $node->namespacedName . '()';
                }
            }
            $node->setAttribute('FQSEN', $name);
            if ($metricValue >= $this->arguments->getOption('complexity-error-threshold')) {
                $finding = new \NdB\PhpDocCheck\Findings\Error(
                    $node,
                    $this->sourceFile,
                    $this->metric,
                    $metricValue
                );
                $this->analysisResult->addProgress($finding);
                $this->groupManager->addFinding($finding);
            } elseif ($metricValue >= $this->arguments->getOption('complexity-warning-threshold')) {
                $finding = new \NdB\PhpDocCheck\Findings\Warning(
                    $node,
                    $this->sourceFile,
                    $this->metric,
                    $metricValue
                );
                $this->analysisResult->addProgress($finding);
                $this->groupManager->addFinding($finding);
            }
        }
    }
public function leaveNode ( \ PhpParser \ Node $ node ) { if ( is_a ( $ node , " \PhpParser\Node\FunctionLike " ) ) { $ metricValue = $ this -> metric -> getValue ( $ node ) ; $ name = 'Anonymous function' ; if ( \ property_exists ( $ node , 'name' ) ) { $ parent = $ node -> getAttribute ( 'parent' ) ; if ( ! empty ( $ parent ) && \ property_exists ( $ parent , 'namespacedName' ) ) { $ name = $ parent -> namespacedName . '::' ; $ name .= $ node -> name . '()' ; } if ( \ property_exists ( $ node , 'namespacedName' ) ) { $ name = $ node -> namespacedName . '()' ; } } $ node -> setAttribute ( 'FQSEN' , $ name ) ; if ( $ metricValue >= $ this -> arguments -> getOption ( 'complexity-error-threshold' ) ) { $ finding = new \ NdB \ PhpDocCheck \ Findings \ Error ( $ node , $ this -> sourceFile , $ this -> metric , $ metricValue ) ; $ this -> analysisResult -> addProgress ( $ finding ) ; $ this -> groupManager -> addFinding ( $ finding ) ; } elseif ( $ metricValue >= $ this -> arguments -> getOption ( 'complexity-warning-threshold' ) ) { $ finding = new \ NdB \ PhpDocCheck \ Findings \ Warning ( $ node , $ this -> sourceFile , $ this -> metric , $ metricValue ) ; $ this -> analysisResult -> addProgress ( $ finding ) ; $ this -> groupManager -> addFinding ( $ finding ) ; } } }
Determines if this node and it's children are of a complexity that could
 use some clarification based on Cyclomatic Complexity.
Determines if this node and it ' s children are of a complexity that could use some clarification based on Cyclomatic Complexity .