Beispiel #1
0
 /**
  * Calculates two metrics. The number of added methods and the number of
  * overwritten methods.
  *
  * @param PHP_Depend_Code_Class $class The context class instance.
  *
  * @return void
  * @since 0.9.10
  */
 private function _calculateNumberOfAddedAndOverwrittenMethods(PHP_Depend_Code_Class $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;
         }
     }
     $uuid = $class->getUUID();
     $this->_nodeMetrics[$uuid][self::M_NUMBER_OF_ADDED_METHODS] = $numberOfAddedMethods;
     $this->_nodeMetrics[$uuid][self::M_NUMBER_OF_OVERWRITTEN_METHODS] = $numberOfOverwrittenMethods;
 }