コード例 #1
0
ファイル: Analyzer.php プロジェクト: KingNoosh/Teknik
 /**
  * Initializes a empty metric container for the given class node.
  *
  * @param PHP_Depend_Code_Class $class The context class instance.
  *
  * @return void
  * @since 0.9.10
  */
 private function initNodeMetricsForClass(PHP_Depend_Code_Class $class)
 {
     $uuid = $class->getUuid();
     if (isset($this->nodeMetrics[$uuid])) {
         return;
     }
     ++$this->numberOfClasses;
     $this->nodeMetrics[$uuid] = array(self::M_DEPTH_OF_INHERITANCE_TREE => 0, self::M_NUMBER_OF_ADDED_METHODS => 0, self::M_NUMBER_OF_DERIVED_CLASSES => 0, self::M_NUMBER_OF_OVERWRITTEN_METHODS => 0);
     foreach ($class->getParentClasses() as $parent) {
         $this->initNodeMetricsForClass($parent);
     }
 }
コード例 #2
0
ファイル: ClassTest.php プロジェクト: rouffj/pdepend
 /**
  * testGetParentClassesReturnsEmptyArrayByDefault
  *
  * @return void
  */
 public function testGetParentClassesReturnsEmptyArrayByDefault()
 {
     $class = new PHP_Depend_Code_Class(__CLASS__);
     $this->assertSame(array(), $class->getParentClasses());
 }
コード例 #3
0
ファイル: Analyzer.php プロジェクト: KingNoosh/Teknik
 /**
  * Calculates the Variables Inheritance of a class metric, this method only
  * counts protected and public properties of parent classes.
  *
  * @param PHP_Depend_Code_Class $class The context class instance.
  *
  * @return integer
  */
 private function calculateVarsi(PHP_Depend_Code_Class $class)
 {
     // List of properties, this method only counts not overwritten properties
     $properties = array();
     // Collect all properties of the context class
     foreach ($class->getProperties() as $prop) {
         $properties[$prop->getName()] = true;
     }
     foreach ($class->getParentClasses() as $parent) {
         foreach ($parent->getProperties() as $prop) {
             if (!$prop->isPrivate() && !isset($properties[$prop->getName()])) {
                 $properties[$prop->getName()] = true;
             }
         }
     }
     return count($properties);
 }