예제 #1
0
 /**
  * Calculates Maintainability Index
  *
  * @param \Hal\Metrics\Complexity\Text\Halstead\Result $rHalstead
  * @param \Hal\Metrics\Complexity\Text\Length\Result $rLoc
  * @param \Hal\Metrics\Complexity\Component\McCabe\Result $rMcCabe
  * @return Result
  */
 public function calculate(\Hal\Metrics\Complexity\Text\Halstead\Result $rHalstead, \Hal\Metrics\Complexity\Text\Length\Result $rLoc, \Hal\Metrics\Complexity\Component\McCabe\Result $rMcCabe)
 {
     $result = new Result();
     $result->setMaintainabilityIndexWithoutComment(max((171 - 5.2 * \log($rHalstead->getVolume()) - 0.23 * $rMcCabe->getCyclomaticComplexityNumber() - 16.2 * \log($rLoc->getLogicalLoc())) * 100 / 171, 0));
     // comment weight
     if ($rLoc->getLoc() > 0) {
         $CM = $rLoc->getCommentLoc() / $rLoc->getLoc();
         $result->setCommentWeight(50 * sin(sqrt(2.4 * $CM)));
     }
     return $result;
 }
예제 #2
0
 /**
  * get the cyclomatic complexity number
  *
  * @return int
  */
 public function getCyclomaticComplexityNumber()
 {
     return !is_null($this->mcCabe) ? $this->mcCabe->getCyclomaticComplexityNumber() : 0;
 }