/** * Visits methods, functions or closures and calculated their complexity. * * @param \PDepend\Source\AST\AbstractASTCallable $callable * @return void * @since 0.9.8 */ public function calculateComplexity(AbstractASTCallable $callable) { $data = array(self::M_CYCLOMATIC_COMPLEXITY_1 => 1, self::M_CYCLOMATIC_COMPLEXITY_2 => 1); foreach ($callable->getChildren() as $child) { $data = $child->accept($this, $data); } $this->metrics[$callable->getId()] = $data; }
/** * This method will calculate the NPath complexity for the given callable * instance. * * @param \PDepend\Source\AST\AbstractASTCallable $callable * @return void * @since 0.9.12 */ protected function calculateComplexity(AbstractASTCallable $callable) { $npath = '1'; foreach ($callable->getChildren() as $child) { $stmt = $child->accept($this, $npath); $npath = MathUtil::mul($npath, $stmt); } $this->metrics[$callable->getId()] = $npath; }