Exemplo n.º 1
0
 /**
  * Returns the percentage code coverage for the given item instance.
  *
  * @param PHP_Depend_Code_AbstractItem $item The context code item.
  *
  * @return float
  */
 public function getCoverage(PHP_Depend_Code_AbstractItem $item)
 {
     $lines = $this->_getLines((string) $item->getSourceFile());
     $startLine = $item->getStartLine();
     $endLine = $item->getEndLine();
     $executable = 0;
     $executed = 0;
     for ($i = $startLine; $i <= $endLine; ++$i) {
         if (!isset($lines[$i])) {
             continue;
         }
         ++$executable;
         if ($lines[$i]) {
             ++$executed;
         }
     }
     if ($executed === 0) {
         return 0;
     }
     return $executed / $executable * 100;
 }
Exemplo n.º 2
0
 /**
  * Returns the begin line for this node in the php source code file.
  *
  * @return integer
  */
 public function getBeginLine()
 {
     return $this->_node->getStartLine();
 }