当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Util_Metrics类代码示例

本文整理汇总了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);
     }
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:7,代码来源:ExcessiveClassLength.php

示例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);
     }
 }
开发者ID:amptools-net,项目名称:midori-php,代码行数:7,代码来源:ExcessiveParameterList.php

示例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);
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:7,代码来源:NPathComplexity.php

示例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);
     }
 }
开发者ID:xiplias,项目名称:pails,代码行数:7,代码来源:ExcessiveMethodLength.php

示例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);
     }
 }
开发者ID:pavan-git,项目名称:visualphpunit,代码行数:7,代码来源:CyclomaticComplexity.php

示例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);
     }
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:7,代码来源:CRAP.php

示例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);
     }
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:7,代码来源:EfferentCoupling.php

示例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);
     }
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:7,代码来源:DepthOfInheritanceTree.php

示例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);
     }
 }
开发者ID:amptools-net,项目名称:midori-php,代码行数:7,代码来源:ExcessivePublicCount.php

示例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);
     }
 }
开发者ID:amptools-net,项目名称:midori-php,代码行数:7,代码来源:TooManyFields.php

示例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);
     }
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:14,代码来源:CodeCoverage.php

示例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]);
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:22,代码来源:CRAP.php


注:本文中的PHPUnit_Util_Metrics类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。