/** * Calculates two metrics. The number of added methods and the number of * overwritten methods. * * @param \PDepend\Source\AST\ASTClass $class * @return void * @since 0.9.10 */ private function calculateNumberOfAddedAndOverwrittenMethods(ASTClass $class) { $parentClass = $class->getParentClass(); if ($parentClass === null) { return; } $parentMethodNames = array(); foreach ($parentClass->getAllMethods() as $method) { $parentMethodNames[$method->getName()] = $method->isAbstract(); } $numberOfAddedMethods = 0; $numberOfOverwrittenMethods = 0; foreach ($class->getAllMethods() as $method) { if ($method->getParent() !== $class) { continue; } if (isset($parentMethodNames[$method->getName()])) { if (!$parentMethodNames[$method->getName()]) { ++$numberOfOverwrittenMethods; } } else { ++$numberOfAddedMethods; } } $id = $class->getId(); $this->nodeMetrics[$id][self::M_NUMBER_OF_ADDED_METHODS] = $numberOfAddedMethods; $this->nodeMetrics[$id][self::M_NUMBER_OF_OVERWRITTEN_METHODS] = $numberOfOverwrittenMethods; }