PDepend\Metrics\Analyzer\NPathComplexityAnalyzer::visitSwitchStatement PHP Method

visitSwitchStatement() public method

switch () ... -- NP(switch) = NP() + NP() + NP() ... --
Since: 0.9.12
public visitSwitchStatement ( PDepend\Source\AST\ASTNode $node, string $data ) : string
$node PDepend\Source\AST\ASTNode The currently visited node.
$data string The previously calculated npath value.
return string
    public function visitSwitchStatement($node, $data)
    {
        $npath = $this->sumComplexity($node->getChild(0));
        foreach ($node->getChildren() as $child) {
            if ($child instanceof ASTSwitchLabel) {
                $label = $child->accept($this, 1);
                $npath = MathUtil::add($npath, $label);
            }
        }
        return MathUtil::mul($npath, $data);
    }