Example #1
0
 /**
  * Constructor.
  *
  * @param $class ReflectionClass       	
  * @param $codeCoverage array       	
  */
 protected function __construct(ReflectionClass $class, &$codeCoverage = array())
 {
     $this->class = $class;
     $className = $class->getName();
     $packageInformation = PHPCoverage_Util_Class::getPackageInformation($className, $class->getDocComment());
     if (!empty($packageInformation['fullPackage'])) {
         $this->package = $packageInformation['fullPackage'];
     }
     $this->setCoverage($codeCoverage);
     $this->dit = count(PHPCoverage_Util_Class::getHierarchy($class->getName())) - 1;
     $this->impl = count($class->getInterfaces());
     foreach ($this->class->getMethods() as $method) {
         if ($method->getDeclaringClass()->getName() == $className) {
             $this->methods[$method->getName()] = PHPCoverage_Util_Metrics_Function::factory($method, $codeCoverage);
         } else {
             $this->inheritedMethods[$method->getName()] = PHPCoverage_Util_Metrics_Function::factory($method, $codeCoverage);
         }
     }
     $this->calculateAttributeMetrics();
     $this->calculateMethodMetrics();
     $this->calculateNumberOfChildren();
     $this->calculatePolymorphismFactor();
     $this->calculateDependencies();
 }
Example #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);
     }
 }