abstract class PHP_CodeCoverage_Report_Node

Base class for nodes in the code coverage information tree.

@category PHP @package CodeCoverage @author Sebastian Bergmann <sebastian@phpunit.de> @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de> @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License @link http://github.com/sebastianbergmann/php-code-coverage @since Class available since Release 1.1.0

Hierarchy

Expanded class hierarchy of PHP_CodeCoverage_Report_Node

File

drupal/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node.php, line 57

View source
abstract class PHP_CodeCoverage_Report_Node implements Countable {

  /**
   * @var string
   */
  protected $name;

  /**
   * @var string
   */
  protected $path;

  /**
   * @var array
   */
  protected $pathArray;

  /**
   * @var PHP_CodeCoverage_Report_Node
   */
  protected $parent;

  /**
   * @var string
   */
  protected $id;

  /**
   * Constructor.
   *
   * @param string                       $name
   * @param PHP_CodeCoverage_Report_Node $parent
   */
  public function __construct($name, PHP_CodeCoverage_Report_Node $parent = NULL) {
    if (substr($name, -1) == '/') {
      $name = substr($name, 0, -1);
    }
    $this->name = $name;
    $this->parent = $parent;
  }

  /**
   * @return string
   */
  public function getName() {
    return $this->name;
  }

  /**
   * @return string
   */
  public function getId() {
    if ($this->id === NULL) {
      $parent = $this
        ->getParent();
      if ($parent === NULL) {
        $this->id = 'index';
      }
      else {
        $parentId = $parent
          ->getId();
        if ($parentId == 'index') {
          $this->id = str_replace(':', '_', $this->name);
        }
        else {
          $this->id = $parentId . '_' . $this->name;
        }
      }
    }
    return $this->id;
  }

  /**
   * @return string
   */
  public function getPath() {
    if ($this->path === NULL) {
      if ($this->parent === NULL) {
        $this->path = $this->name;
      }
      else {
        $this->path = $this->parent
          ->getPath() . '/' . $this->name;
      }
    }
    return $this->path;
  }

  /**
   * @return array
   */
  public function getPathAsArray() {
    if ($this->pathArray === NULL) {
      if ($this->parent === NULL) {
        $this->pathArray = array();
      }
      else {
        $this->pathArray = $this->parent
          ->getPathAsArray();
      }
      $this->pathArray[] = $this;
    }
    return $this->pathArray;
  }

  /**
   * @return PHP_CodeCoverage_Report_Node
   */
  public function getParent() {
    return $this->parent;
  }

  /**
   * Returns the percentage of classes that has been tested.
   *
   * @param  boolean $asString
   * @return integer
   */
  public function getTestedClassesPercent($asString = TRUE) {
    return PHP_CodeCoverage_Util::percent($this
      ->getNumTestedClasses(), $this
      ->getNumClasses(), $asString);
  }

  /**
   * Returns the percentage of traits that has been tested.
   *
   * @param  boolean $asString
   * @return integer
   */
  public function getTestedTraitsPercent($asString = TRUE) {
    return PHP_CodeCoverage_Util::percent($this
      ->getNumTestedTraits(), $this
      ->getNumTraits(), $asString);
  }

  /**
   * Returns the percentage of traits that has been tested.
   *
   * @param  boolean $asString
   * @return integer
   * @since  Method available since Release 1.2.0
   */
  public function getTestedClassesAndTraitsPercent($asString = TRUE) {
    return PHP_CodeCoverage_Util::percent($this
      ->getNumTestedClassesAndTraits(), $this
      ->getNumClassesAndTraits(), $asString);
  }

  /**
   * Returns the percentage of methods that has been tested.
   *
   * @param  boolean $asString
   * @return integer
   */
  public function getTestedMethodsPercent($asString = TRUE) {
    return PHP_CodeCoverage_Util::percent($this
      ->getNumTestedMethods(), $this
      ->getNumMethods(), $asString);
  }

  /**
   * Returns the percentage of executed lines.
   *
   * @param  boolean $asString
   * @return integer
   */
  public function getLineExecutedPercent($asString = TRUE) {
    return PHP_CodeCoverage_Util::percent($this
      ->getNumExecutedLines(), $this
      ->getNumExecutableLines(), $asString);
  }

  /**
   * Returns the number of classes and traits.
   *
   * @return integer
   * @since  Method available since Release 1.2.0
   */
  public function getNumClassesAndTraits() {
    return $this
      ->getNumClasses() + $this
      ->getNumTraits();
  }

  /**
   * Returns the number of tested classes and traits.
   *
   * @return integer
   * @since  Method available since Release 1.2.0
   */
  public function getNumTestedClassesAndTraits() {
    return $this
      ->getNumTestedClasses() + $this
      ->getNumTestedTraits();
  }

  /**
   * Returns the classes and traits of this node.
   *
   * @return array
   * @since  Method available since Release 1.2.0
   */
  public function getClassesAndTraits() {
    return array_merge($this
      ->getClasses(), $this
      ->getTraits());
  }

  /**
   * Returns the classes of this node.
   *
   * @return array
   */
  public abstract function getClasses();

  /**
   * Returns the traits of this node.
   *
   * @return array
   */
  public abstract function getTraits();

  /**
   * Returns the functions of this node.
   *
   * @return array
   */
  public abstract function getFunctions();

  /**
   * Returns the LOC/CLOC/NCLOC of this node.
   *
   * @return array
   */
  public abstract function getLinesOfCode();

  /**
   * Returns the number of executable lines.
   *
   * @return integer
   */
  public abstract function getNumExecutableLines();

  /**
   * Returns the number of executed lines.
   *
   * @return integer
   */
  public abstract function getNumExecutedLines();

  /**
   * Returns the number of classes.
   *
   * @return integer
   */
  public abstract function getNumClasses();

  /**
   * Returns the number of tested classes.
   *
   * @return integer
   */
  public abstract function getNumTestedClasses();

  /**
   * Returns the number of traits.
   *
   * @return integer
   */
  public abstract function getNumTraits();

  /**
   * Returns the number of tested traits.
   *
   * @return integer
   */
  public abstract function getNumTestedTraits();

  /**
   * Returns the number of methods.
   *
   * @return integer
   */
  public abstract function getNumMethods();

  /**
   * Returns the number of tested methods.
   *
   * @return integer
   */
  public abstract function getNumTestedMethods();

  /**
   * Returns the number of functions.
   *
   * @return integer
   */
  public abstract function getNumFunctions();

  /**
   * Returns the number of tested functions.
   *
   * @return integer
   */
  public abstract function getNumTestedFunctions();

}

Members

Namesort descending Modifiers Type Description Overrides
PHP_CodeCoverage_Report_Node::$id protected property
PHP_CodeCoverage_Report_Node::$name protected property
PHP_CodeCoverage_Report_Node::$parent protected property
PHP_CodeCoverage_Report_Node::$path protected property
PHP_CodeCoverage_Report_Node::$pathArray protected property
PHP_CodeCoverage_Report_Node::getClasses abstract public function Returns the classes of this node. 2
PHP_CodeCoverage_Report_Node::getClassesAndTraits public function Returns the classes and traits of this node.
PHP_CodeCoverage_Report_Node::getFunctions abstract public function Returns the functions of this node. 2
PHP_CodeCoverage_Report_Node::getId public function
PHP_CodeCoverage_Report_Node::getLineExecutedPercent public function Returns the percentage of executed lines.
PHP_CodeCoverage_Report_Node::getLinesOfCode abstract public function Returns the LOC/CLOC/NCLOC of this node. 2
PHP_CodeCoverage_Report_Node::getName public function
PHP_CodeCoverage_Report_Node::getNumClasses abstract public function Returns the number of classes. 2
PHP_CodeCoverage_Report_Node::getNumClassesAndTraits public function Returns the number of classes and traits.
PHP_CodeCoverage_Report_Node::getNumExecutableLines abstract public function Returns the number of executable lines. 2
PHP_CodeCoverage_Report_Node::getNumExecutedLines abstract public function Returns the number of executed lines. 2
PHP_CodeCoverage_Report_Node::getNumFunctions abstract public function Returns the number of functions. 2
PHP_CodeCoverage_Report_Node::getNumMethods abstract public function Returns the number of methods. 2
PHP_CodeCoverage_Report_Node::getNumTestedClasses abstract public function Returns the number of tested classes. 2
PHP_CodeCoverage_Report_Node::getNumTestedClassesAndTraits public function Returns the number of tested classes and traits.
PHP_CodeCoverage_Report_Node::getNumTestedFunctions abstract public function Returns the number of tested functions. 2
PHP_CodeCoverage_Report_Node::getNumTestedMethods abstract public function Returns the number of tested methods. 2
PHP_CodeCoverage_Report_Node::getNumTestedTraits abstract public function Returns the number of tested traits. 2
PHP_CodeCoverage_Report_Node::getNumTraits abstract public function Returns the number of traits. 2
PHP_CodeCoverage_Report_Node::getParent public function
PHP_CodeCoverage_Report_Node::getPath public function
PHP_CodeCoverage_Report_Node::getPathAsArray public function
PHP_CodeCoverage_Report_Node::getTestedClassesAndTraitsPercent public function Returns the percentage of traits that has been tested.
PHP_CodeCoverage_Report_Node::getTestedClassesPercent public function Returns the percentage of classes that has been tested.
PHP_CodeCoverage_Report_Node::getTestedMethodsPercent public function Returns the percentage of methods that has been tested.
PHP_CodeCoverage_Report_Node::getTestedTraitsPercent public function Returns the percentage of traits that has been tested.
PHP_CodeCoverage_Report_Node::getTraits abstract public function Returns the traits of this node. 2
PHP_CodeCoverage_Report_Node::__construct public function Constructor. 1