fpreach ()
S;
-- NP(foreach) = NP() + NP() + 1 --
public visitForeachStatement ( PDepend\Source\AST\ASTNode $node, string $data ) : string | ||
$node | PDepend\Source\AST\ASTNode | The currently visited node. |
$data | string | The previously calculated npath value. |
Результат | string |
public function visitForeachStatement($node, $data)
{
$npath = $this->sumComplexity($node->getChild(0));
$npath = MathUtil::add($npath, '1');
foreach ($node->getChildren() as $child) {
if ($child instanceof ASTStatement) {
$stmt = $child->accept($this, 1);
$npath = MathUtil::add($npath, $stmt);
}
}
return MathUtil::mul($npath, $data);
}