本文整理汇总了PHP中PHPUnit_Util_Metrics类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Metrics类的具体用法?PHP PHPUnit_Util_Metrics怎么用?PHP PHPUnit_Util_Metrics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Util_Metrics类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$locExecutable = $metrics->getLocExecutable();
if ($locExecutable > $this->threshold) {
return sprintf("Class has %d lines of executable code.\n" . 'This is an indication that the class may be ' . 'trying to do too much. Try to break it down, ' . 'and reduce the size to something manageable.', $locExecutable);
}
}
示例2: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$parameters = $metrics->getParameters();
if ($parameters >= $this->threshold) {
return sprintf("Function or method has %d parameters.\n" . 'Long parameter lists can indicate that a new object should be ' . 'created to wrap the numerous parameters. Basically, try to ' . 'group the parameters together.', $parameters);
}
}
示例3: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$npath = $metrics->getNPath();
if ($npath >= $this->threshold) {
return sprintf("The NPath complexity is %d.\n" . 'The NPath complexity of a function or method is the number of ' . 'acyclic execution paths through that method. A threshold of 200 ' . 'is generally considered the point where measures should be taken ' . 'to reduce complexity.', $npath);
}
}
示例4: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$locExecutable = $metrics->getLocExecutable();
if ($locExecutable >= $this->threshold) {
return sprintf("Function or method has %d lines of executable code.\n" . 'Violations of this rule usually indicate that the method is ' . 'doing too much. Try to reduce the method size by creating ' . 'helper methods and removing any copy/pasted code.', $locExecutable);
}
}
示例5: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$ccn = $metrics->getCCN();
if ($ccn >= $this->threshold) {
return sprintf("The cyclomatic complexity is %d.\n" . 'Complexity is determined by the number of decision points in a ' . 'function or method plus one for the function or method entry. ' . 'The decision points are "if", "for", "foreach", "while", "case", ' . '"catch", "&&", "||", and "?:". Generally, 1-4 is low ' . 'complexity, 5-7 indicates moderate complexity, 8-10 is high ' . 'complexity, and 11+ is very high complexity.', $ccn);
}
}
示例6: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$crap = $metrics->getCrapIndex();
if ($crap >= $this->threshold) {
return sprintf("The CRAP index is %d.\n" . 'The Change Risk Analysis and Predictions (CRAP) index of a ' . 'function or method uses cyclomatic complexity and code coverage ' . 'from automated tests to help estimate the effort and risk ' . 'associated with maintaining legacy code. A CRAP index over 30 ' . 'is a good indicator of crappy code.', $crap);
}
}
示例7: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$ce = $metrics->getCe();
if ($ce > $this->threshold) {
return sprintf("Class depends on %d other classes.\n" . 'The number of other classes that the class ' . 'depends upon is an indicator of the class\' ' . 'independence.', $ce);
}
}
示例8: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$dit = $metrics->getDIT();
if ($dit > $this->threshold) {
return sprintf('Depth of Inheritance Tree (DIT) is %d.', $dit);
}
}
示例9: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$publicMethods = $metrics->getPublicMethods();
if ($publicMethods > $this->threshold) {
return sprintf("Class has %d public methods.\n" . 'A large number of public methods and attributes ' . 'declared in a class can indicate the class may need ' . 'to be broken up as increased effort will be required ' . 'to thoroughly test it.', $publicMethods);
}
}
示例10: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$varsNp = $metrics->getVARSnp();
if ($varsNp > $this->threshold) {
return sprintf("Class has %d public fields.\n" . 'Classes that have too many fields could be redesigned ' . 'to have fewer fields, possibly through some nested ' . 'object grouping of some of the information. For ' . 'example, a class with city/state/zip fields could ' . 'instead have one Address field.', $varsNp);
}
}
示例11: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$coverage = $metrics->getCoverage();
if ($coverage <= $this->threshold[0]) {
$violation = 'The code coverage is %01.2F which is considered low.';
} else {
if ($coverage > $this->threshold[0] && $coverage < $this->threshold[1]) {
$violation = 'The code coverage is %01.2F which is considered medium.';
}
}
if (isset($violation)) {
return sprintf($violation, $coverage);
}
}
示例12: apply
public function apply(PHPUnit_Util_Metrics $metrics)
{
$numCrappyMethods = 0;
$numMethods = 0;
foreach ($metrics->getClasses() as $class) {
$methods = $class->getMethods();
foreach ($methods as $method) {
if ($method->getCrapIndex() > $this->threshold[1]) {
$numCrappyMethods++;
}
}
$numMethods += count($methods);
}
if ($numMethods > 0) {
$percent = $numCrappyMethods / $numMethods * 100;
} else {
$percent = 0;
}
if ($percent > $this->threshold[0]) {
return sprintf("More than %01.2f%% of the project's methods have a Change Risk " . 'Analysis and Predictions (CRAP) index that is above the threshold ' . "of %d.\n" . 'The CRAP index of a function or method uses cyclomatic complexity ' . 'and code coverage from automated tests to help estimate the ' . 'effort and risk associated with maintaining legacy code. A CRAP ' . 'index over 30 is a good indicator of crappy code.', $this->threshold[0], $this->threshold[1]);
}
}