|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * PHP_CodeCoverage |
| 4 | + * |
| 5 | + * Copyright (c) 2009-2011, Sebastian Bergmann <[email protected]>. |
| 6 | + * All rights reserved. |
| 7 | + * |
| 8 | + * Redistribution and use in source and binary forms, with or without |
| 9 | + * modification, are permitted provided that the following conditions |
| 10 | + * are met: |
| 11 | + * |
| 12 | + * * Redistributions of source code must retain the above copyright |
| 13 | + * notice, this list of conditions and the following disclaimer. |
| 14 | + * |
| 15 | + * * Redistributions in binary form must reproduce the above copyright |
| 16 | + * notice, this list of conditions and the following disclaimer in |
| 17 | + * the documentation and/or other materials provided with the |
| 18 | + * distribution. |
| 19 | + * |
| 20 | + * * Neither the name of Sebastian Bergmann nor the names of his |
| 21 | + * contributors may be used to endorse or promote products derived |
| 22 | + * from this software without specific prior written permission. |
| 23 | + * |
| 24 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 25 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 26 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 27 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 28 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 29 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 30 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 31 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 32 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 33 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 34 | + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 35 | + * POSSIBILITY OF SUCH DAMAGE. |
| 36 | + * |
| 37 | + * @category PHP |
| 38 | + * @package CodeCoverage |
| 39 | + * @author Sebastian Bergmann <[email protected]> |
| 40 | + * @copyright 2009-2011 Sebastian Bergmann <[email protected]> |
| 41 | + * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
| 42 | + * @link http://github.com/sebastianbergmann/php-code-coverage |
| 43 | + * @since File available since Release 1.1.0 |
| 44 | + */ |
| 45 | + |
| 46 | +/** |
| 47 | + * Base class for nodes in the code coverage information tree. |
| 48 | + * |
| 49 | + * @category PHP |
| 50 | + * @package CodeCoverage |
| 51 | + * @author Sebastian Bergmann <[email protected]> |
| 52 | + * @copyright 2009-2011 Sebastian Bergmann <[email protected]> |
| 53 | + * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
| 54 | + * @version Release: @package_version@ |
| 55 | + * @link http://github.com/sebastianbergmann/php-code-coverage |
| 56 | + * @since Class available since Release 1.1.0 |
| 57 | + */ |
| 58 | +abstract class PHP_CodeCoverage_Report_Node |
| 59 | +{ |
| 60 | + /** |
| 61 | + * @var string |
| 62 | + */ |
| 63 | + protected $name; |
| 64 | + |
| 65 | + /** |
| 66 | + * @var string |
| 67 | + */ |
| 68 | + protected $path; |
| 69 | + |
| 70 | + /** |
| 71 | + * @var PHP_CodeCoverage_Report_Node |
| 72 | + */ |
| 73 | + protected $parent; |
| 74 | + |
| 75 | + /** |
| 76 | + * Constructor. |
| 77 | + * |
| 78 | + * @param string $name |
| 79 | + * @param string $path |
| 80 | + * @param PHP_CodeCoverage_Report_Node $parent |
| 81 | + */ |
| 82 | + public function __construct($name, $path, PHP_CodeCoverage_Report_Node $parent = NULL) |
| 83 | + { |
| 84 | + $this->name = $name; |
| 85 | + $this->path = $path; |
| 86 | + $this->parent = $parent; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * @return string |
| 91 | + */ |
| 92 | + public function getName() |
| 93 | + { |
| 94 | + return $this->name; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * @return string |
| 99 | + */ |
| 100 | + public function getPath() |
| 101 | + { |
| 102 | + return $this->path; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * @return PHP_CodeCoverage_Report_Node |
| 107 | + */ |
| 108 | + public function getParent() |
| 109 | + { |
| 110 | + return $this->parent; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Returns the percentage of classes that has been tested. |
| 115 | + * |
| 116 | + * @return integer |
| 117 | + */ |
| 118 | + public function getTestedClassesPercent() |
| 119 | + { |
| 120 | + return PHP_CodeCoverage_Util::percent( |
| 121 | + $this->getNumTestedClasses(), |
| 122 | + $this->getNumClasses(), |
| 123 | + TRUE |
| 124 | + ); |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Returns the percentage of methods that has been tested. |
| 129 | + * |
| 130 | + * @return integer |
| 131 | + */ |
| 132 | + public function getTestedMethodsPercent() |
| 133 | + { |
| 134 | + return PHP_CodeCoverage_Util::percent( |
| 135 | + $this->getNumTestedMethods(), |
| 136 | + $this->getNumMethods(), |
| 137 | + TRUE |
| 138 | + ); |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * Returns the percentage of executed lines. |
| 143 | + * |
| 144 | + * @return integer |
| 145 | + */ |
| 146 | + public function getLineExecutedPercent() |
| 147 | + { |
| 148 | + return PHP_CodeCoverage_Util::percent( |
| 149 | + $this->getNumExecutedLines(), |
| 150 | + $this->getNumExecutableLines(), |
| 151 | + TRUE |
| 152 | + ); |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Returns the classes of this node. |
| 157 | + * |
| 158 | + * @return array |
| 159 | + */ |
| 160 | + abstract public function getClasses(); |
| 161 | + |
| 162 | + /** |
| 163 | + * Returns the number of executable lines. |
| 164 | + * |
| 165 | + * @return integer |
| 166 | + */ |
| 167 | + abstract public function getNumExecutableLines(); |
| 168 | + |
| 169 | + /** |
| 170 | + * Returns the number of executed lines. |
| 171 | + * |
| 172 | + * @return integer |
| 173 | + */ |
| 174 | + abstract public function getNumExecutedLines(); |
| 175 | + |
| 176 | + /** |
| 177 | + * Returns the number of classes. |
| 178 | + * |
| 179 | + * @return integer |
| 180 | + */ |
| 181 | + abstract public function getNumClasses(); |
| 182 | + |
| 183 | + /** |
| 184 | + * Returns the number of tested classes. |
| 185 | + * |
| 186 | + * @return integer |
| 187 | + */ |
| 188 | + abstract public function getNumTestedClasses(); |
| 189 | + |
| 190 | + /** |
| 191 | + * Returns the number of methods. |
| 192 | + * |
| 193 | + * @return integer |
| 194 | + */ |
| 195 | + abstract public function getNumMethods(); |
| 196 | + |
| 197 | + /** |
| 198 | + * Returns the number of tested methods. |
| 199 | + * |
| 200 | + * @return integer |
| 201 | + */ |
| 202 | + abstract public function getNumTestedMethods(); |
| 203 | +} |
0 commit comments