コード例 #1
0
ファイル: Analyzer.php プロジェクト: kingsj/core
 /**
  * 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;
     }
     // Get parent class and collect all non private properties
     $parent = $class->getParentClass();
     while ($parent !== null) {
         // Get all parent properties
         foreach ($parent->getProperties() as $prop) {
             if (!$prop->isPrivate() && !isset($properties[$prop->getName()])) {
                 $properties[$prop->getName()] = true;
             }
         }
         // Get next parent
         $parent = $parent->getParentClass();
     }
     return count($properties);
 }
コード例 #2
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);
 }