Example #1
0
 /**
  * Calculate abstractness
  *
  * @param ResultCollection $results Array of ResultSet
  * @return Result
  */
 public function calculate(ResultCollection $results)
 {
     $ac = $cc = $abstractness = 0;
     foreach ($results as $result) {
         $rOOP = $result->getOOP();
         $cc += sizeof($rOOP->getConcreteClasses(), COUNT_NORMAL);
         $ac += sizeof($rOOP->getAbstractClasses(), COUNT_NORMAL);
     }
     $result = new Result();
     if ($ac + $cc > 0) {
         $abstractness = round($ac / ($ac + $cc), 2);
     }
     $result->setAbstractness($abstractness);
     return $result;
 }
Example #2
0
 public function testAbstractnessResultCanBeConvertedToArray()
 {
     $result = new Result();
     $array = $result->asArray();
     $this->assertArrayHasKey('abstractness', $array);
 }