public function testCouplingTakesCareOfReturnedValues() { $filename = __DIR__ . '/../../../../../resources/coupling/f1.php'; $extractor = new Extractor(new Tokenizer()); $classmap = new ClassMap(); $classmap->push($filename, $extractor->extract($filename)); $coupling = new Coupling(); $this->result = $coupling->calculate($classmap); $this->assertEquals(0, $this->result->get('\\ClassWhoUseAnother')->getAfferentCoupling()); $this->assertEquals(1, $this->result->get('\\ClassWhoUseAnother')->getEfferentCoupling()); $this->assertEquals(1, $this->result->get('\\ClassWhoIsUsed')->getAfferentCoupling()); $this->assertEquals(0, $this->result->get('\\ClassWhoIsUsed')->getEfferentCoupling()); }
/** * 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; }