/** * Returns a child node at the given index. * * @param integer $index The child offset. * * @return PHP_PMD_Node_ASTNode */ public function getChild($index) { return new PHP_PMD_Node_ASTNode($this->_node->getChild($index), $this->getFileName()); }
/** * This method calculates the NPath Complexity of a while-statement, the * meassured value is then returned as a string. * * <code> * while (<expr>) * <while-range> * S; * * -- NP(while) = NP(<while-range>) + NP(<expr>) + 1 -- * </code> * * @param PHP_Depend_Code_ASTNode $node The currently visited node. * @param string $data The previously calculated npath value. * * @return string * @since 0.9.12 */ public function visitWhileStatement($node, $data) { $expr = $this->sumComplexity($node->getChild(0)); $stmt = $node->getChild(1)->accept($this, 1); $npath = PHP_Depend_Util_MathUtil::add($expr, $stmt); $npath = PHP_Depend_Util_MathUtil::add($npath, '1'); return PHP_Depend_Util_MathUtil::mul($npath, $data); }