Exemplo n.º 1
0
 public function testICanKnowTheInstabilityOfPackage()
 {
     $results = new ResultCollection();
     $coupling = $this->getMockBuilder('\\Hal\\Metrics\\Complexity\\Structural\\HenryAndKafura\\Result')->disableOriginalConstructor()->getMock();
     $coupling->expects($this->any())->method('getAfferentCoupling')->will($this->returnValue(1.5));
     $coupling->expects($this->any())->method('getEfferentCoupling')->will($this->returnValue(0.8));
     $resultSet = $this->getMockBuilder('\\Hal\\Component\\Result\\ResultSet')->disableOriginalConstructor()->getMock();
     $resultSet->expects($this->any())->method('getCoupling')->will($this->returnValue($coupling));
     $results->push($resultSet);
     $instability = new Instability();
     $r = $instability->calculate($results);
     $this->assertEquals(0.35, $r->getInstability());
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function execute(ResultCollection $collection, ResultCollection $aggregatedResults)
 {
     $this->output->write(str_pad("\rGrouping results by package/directory. This will take few minutes...", 80, " "));
     // Aggregates results
     $groupedResults = $this->aggregator->aggregates($collection);
     // metrics tools
     $abstractness = new Abstractness();
     $bounds = new Bounds();
     $instability = new Instability();
     foreach ($groupedResults as $namespace => $results) {
         // we filter aggregates to conserve only direct results
         $childs = new ResultCollection();
         foreach ($results as $r) {
             if ($namespace === dirname($r->getName())) {
                 $childs->push($r);
             }
         }
         $resultAggregate = new ResultAggregate($namespace);
         $resultAggregate->setAbstractness($abstractness->calculate($results))->setInstability($instability->calculate($results))->setBounds($bounds->calculate($results))->setChilds($childs);
         $aggregatedResults->push($resultAggregate);
     }
 }