public function __construct($threshold = null) { parent::__construct(self::MEASURE_MAX, $threshold ?: self::DEFAULT_THRESHOLD); }
private function renderExtremeValue($label, ExtremeValue $extremeValue) { $writer = $this->getWriter(); $writer->write(' <oxid:rule'); $this->maybeAdd('name', $label); $this->maybeAdd('threshold', $extremeValue->getThreshold()); $this->maybeAdd('value', $extremeValue->getValue()); $this->maybeAdd('factor', $extremeValue->getFactor()); $this->maybeAdd('violated', $extremeValue->getFactor() > 1.0 ? 'true' : 'false'); $writer->write('>' . PHP_EOL); foreach ($extremeValue->getViolations() as $violation) { $writer->write(' <oxid:file'); $this->maybeAdd('path', $violation->getFileName()); $this->maybeAdd('line', $violation->getBeginLine()); $this->maybeAdd('namespace', $violation->getNamespaceName()); $this->maybeAdd('class', $violation->getClassName()); $this->maybeAdd('method', $violation->getMethodName()); $writer->write(' />' . PHP_EOL); } $writer->write(' </oxid:rule>' . PHP_EOL); }
/** * Returns overall factor for all extreme values. * * @return float|int */ public function calculateFactor() { return $this->coverage->getFactor() * $this->crapIndex->getFactor() * $this->npath->getFactor() * $this->ccn->getFactor(); }
private function renderExtremeValue($label, ExtremeValue $extremeValue) { $writer = $this->getWriter(); $writer->write(str_pad(" {$label}", 45, ' ', STR_PAD_RIGHT)); $writer->write(sprintf('% 10.2f', $extremeValue->getValue())); $writer->write(' '); $writer->write(sprintf('% 7.2f', $extremeValue->getFactor())); $writer->write(PHP_EOL); foreach ($extremeValue->getViolations() as $violation) { $this->renderPath($violation->getFileName(), $violation->getBeginLine()); } }