99 */
1010
1111/**
12- * @category PHP
13- * @package CodeCoverage
14- * @author Zsolt Takács <zsolt@takacs.cc>
15- * @copyright Sebastian Bergmann <sebastian@phpunit.de>
16- * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
17- * @link http://github.com/sebastianbergmann/php-code-coverage
18- * @since Class available since Release 2.0.0
12+ * @since Class available since Release 2.0.0
1913 */
2014class PHP_CodeCoverage_Report_Crap4j
2115{
22- private $ threshold = 30 ;
16+ /**
17+ * @var int
18+ */
19+ private $ threshold ;
20+
21+ /**
22+ * @param int $threshold
23+ */
24+ public function __construct ($ threshold = 30 )
25+ {
26+ if (!is_int ($ threshold )) {
27+ throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory (
28+ 1 ,
29+ 'integer '
30+ );
31+ }
32+
33+ $ this ->threshold = $ threshold ;
34+ }
2335
2436 /**
2537 * @param PHP_CodeCoverage $coverage
@@ -116,9 +128,16 @@ public function process(PHP_CodeCoverage $coverage, $target = null, $name = null
116128 }
117129 }
118130
131+ /**
132+ * @param float $crapValue
133+ * @param integer $cyclomaticComplexity
134+ * @param float $coveragePercent
135+ * @return float
136+ */
119137 private function getCrapLoad ($ crapValue , $ cyclomaticComplexity , $ coveragePercent )
120138 {
121139 $ crapLoad = 0 ;
140+
122141 if ($ crapValue >= $ this ->threshold ) {
123142 $ crapLoad += $ cyclomaticComplexity * (1.0 - $ coveragePercent / 100 );
124143 $ crapLoad += $ cyclomaticComplexity / $ this ->threshold ;
@@ -127,6 +146,10 @@ private function getCrapLoad($crapValue, $cyclomaticComplexity, $coveragePercent
127146 return $ crapLoad ;
128147 }
129148
149+ /**
150+ * @param float $value
151+ * @return float
152+ */
130153 private function roundValue ($ value )
131154 {
132155 return round ($ value , 2 );
0 commit comments