當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。