/** * Visits the given callable instance. * * @param PHP_Depend_Code_AbstractCallable $callable The context callable. * * @return void */ private function _visitCallable(PHP_Depend_Code_AbstractCallable $callable) { $this->_metrics[$callable->getUUID()] = array(self::M_CRAP_INDEX => $this->_calculateCrapIndex($callable)); }
/** * This method will calculate the NPath complexity for the given callable * instance. * * @param PHP_Depend_Code_AbstractCallable $callable The context callable. * * @return void * @since 0.9.12 */ protected function calculateComplexity(PHP_Depend_Code_AbstractCallable $callable) { $npath = '1'; foreach ($callable->getChildren() as $child) { $stmt = $child->accept($this, $npath); $npath = PHP_Depend_Util_MathUtil::mul($npath, $stmt); } $this->_metrics[$callable->getUUID()] = $npath; }
/** * Visits methods, functions or closures and calculated their complexity. * * @param PHP_Depend_Code_AbstractCallable $callable The visited callable. * * @return void * @since 0.9.8 */ public function calculateComplexity(PHP_Depend_Code_AbstractCallable $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->_storeNodeComplexityAndUpdateProject($callable->getUUID(), $data); }