Exemple #1
0
 /**
  * Calculates the Number of Children (NOC) metric for the class.
  */
 protected function calculateNumberOfChildren()
 {
     $className = $this->class->getName();
     if (!isset(self::$nocCache[$className])) {
         self::$nocCache = array();
     }
     if (empty(self::$nocCache)) {
         foreach (get_declared_classes() as $_className) {
             $class = new ReflectionClass($_className);
             $parent = $class->getParentClass();
             if ($parent !== FALSE) {
                 $parentName = $parent->getName();
                 if (isset(self::$nocCache[$parentName])) {
                     self::$nocCache[$parentName]++;
                 } else {
                     self::$nocCache[$parentName] = 1;
                 }
             }
         }
     }
     if (isset(self::$nocCache[$className])) {
         $this->noc = self::$nocCache[$className];
     }
 }
Exemple #2
0
 /**
  * Constructor.
  *
  * @param $filename string       	
  * @param $codeCoverage array       	
  * @throws RuntimeException
  */
 protected function __construct($filename, &$codeCoverage = array())
 {
     if (!file_exists($filename)) {
         throw new RuntimeException(sprintf('File "%s" not found.', $filename));
     }
     $this->filename = $filename;
     foreach (PHPCoverage_Util_File::countLines($this->filename) as $name => $value) {
         $this->{$name} = $value;
     }
     $this->setCoverage($codeCoverage);
     foreach (PHPCoverage_Util_File::getClassesInFile($filename) as $className => $class) {
         $this->classes[$className] = PHPCoverage_Util_Metrics_Class::factory(new ReflectionClass($className), $codeCoverage);
     }
     foreach (PHPCoverage_Util_File::getFunctionsInFile($filename) as $functionName => $function) {
         $this->functions[$functionName] = PHPCoverage_Util_Metrics_Function::factory(new ReflectionFunction($functionName), $codeCoverage);
     }
 }