PDepend\Metrics\Analyzer\InheritanceAnalyzer::calculateNumberOfAddedAndOverwrittenMethods PHP Method

calculateNumberOfAddedAndOverwrittenMethods() private method

Calculates two metrics. The number of added methods and the number of overwritten methods.
Since: 0.9.10
private calculateNumberOfAddedAndOverwrittenMethods ( PDepend\Source\AST\ASTClass $class ) : void
$class PDepend\Source\AST\ASTClass
return void
    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;
    }