Пример #1
0
 protected function processFunctions()
 {
     $functions = PHPCoverage_Util_File::getFunctionsInFile($this->getPath());
     if (count($functions) > 0 && !isset($this->classes['*'])) {
         $this->classes['*'] = array('methods' => array(), 'startLine' => 0, 'executableLines' => 0, 'executedLines' => 0);
     }
     foreach ($functions as $functionName => $function) {
         $this->classes['*']['methods'][$functionName] = array('signature' => $function['signature'], 'startLine' => $function['startLine'], 'executableLines' => 0, 'executedLines' => 0);
         $this->startLines[$function['startLine']] =& $this->classes['*']['methods'][$functionName];
         $this->endLines[$function['endLine']] =& $this->classes['*']['methods'][$functionName];
         $this->numMethods++;
     }
 }
Пример #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);
     }
 }