Пример #1
0
 /**
  * @dataProvider provideValues
  */
 public function testMaintenabilityIndexWithoutCommentIsWellCalculated($cc, $lloc, $cloc, $volume, $MIwoC)
 {
     $rLoc = $this->getMock('\\Hal\\Metrics\\Complexity\\Text\\Length\\Result');
     $rLoc->expects($this->once())->method('getLogicalLoc')->will($this->returnValue($lloc));
     $rHalstead = $this->getMock('\\Hal\\Metrics\\Complexity\\Text\\Halstead\\Result');
     $rHalstead->expects($this->once())->method('getVolume')->will($this->returnValue($volume));
     $rMcCabe = $this->getMock('\\Hal\\Metrics\\Complexity\\Component\\McCabe\\Result');
     $rMcCabe->expects($this->once())->method('getCyclomaticComplexityNumber')->will($this->returnValue($cc));
     $object = new MaintenabilityIndex();
     $result = $object->calculate($rHalstead, $rLoc, $rMcCabe);
     $this->assertEquals($MIwoC, $result->getMaintenabilityIndexWithoutComment());
 }
Пример #2
0
 /**
  * Run analyze
  *
  * @param $filename
  * @return \Hal\Component\Result\ResultSet
  */
 public function execute($filename)
 {
     $rHalstead = $this->halstead->calculate($filename);
     $rLoc = $this->loc->calculate($filename);
     $rMcCabe = $this->mcCabe->calculate($filename);
     $rMyer = $this->myer->calculate($filename);
     $rMaintenability = $this->maintenabilityIndex->calculate($rHalstead, $rLoc, $rMcCabe);
     $resultSet = new \Hal\Component\Result\ResultSet($filename);
     $resultSet->setLoc($rLoc)->setMcCabe($rMcCabe)->setMyer($rMyer)->setHalstead($rHalstead)->setMaintenabilityIndex($rMaintenability);
     if ($this->withOOP) {
         $rOOP = $this->extractor->extract($filename);
         $this->classMap->push($filename, $rOOP);
         $resultSet->setOOP($rOOP);
     }
     return $resultSet;
 }