| Conditions | 18 |
| Paths | 24 |
| Total Lines | 71 |
| Code Lines | 49 |
| Lines | 48 |
| Ratio | 67.61 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 66 | public function getErrorStreamTemplate(CoverFishMapping $coverMapping, $noAnsiColors = false) |
||
| 67 | { |
||
| 68 | $coverLine = null; |
||
| 69 | switch ($this->getMessageCode()) { |
||
| 70 | View Code Duplication | case self::PHPUNIT_REFLECTION_CLASS_NOT_FOUND: |
|
| 71 | $coverLine = sprintf('@covers %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod()); |
||
| 72 | if (!$noAnsiColors) { |
||
| 73 | $coverLine = Color::tplNormalColor('@covers '); |
||
| 74 | $coverLine .= Color::tplMarkFailure($coverMapping->getClassFQN()); |
||
| 75 | $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod()); |
||
| 76 | } |
||
| 77 | |||
| 78 | if (null === $coverMapping->getMethod()) { |
||
| 79 | $coverLine = str_replace('::', null, $coverLine); |
||
| 80 | } |
||
| 81 | |||
| 82 | break; |
||
| 83 | |||
| 84 | View Code Duplication | case self::PHPUNIT_REFLECTION_METHOD_NOT_FOUND: |
|
| 85 | $coverLine = sprintf('@covers %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod()); |
||
| 86 | if (!$noAnsiColors) { |
||
| 87 | $coverLine = Color::tplNormalColor('@covers '); |
||
| 88 | $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN() . '::'); |
||
| 89 | $coverLine .= Color::tplMarkFailure($coverMapping->getMethod()); |
||
| 90 | } |
||
| 91 | |||
| 92 | break; |
||
| 93 | |||
| 94 | View Code Duplication | case self::PHPUNIT_REFLECTION_CLASS_NOT_DEFINED: |
|
| 95 | $coverLine = sprintf('@covers %s', $coverMapping->getClassFQN()); |
||
| 96 | if (!$noAnsiColors) { |
||
| 97 | $coverLine = Color::tplNormalColor('@covers '); |
||
| 98 | $coverLine .= Color::tplMarkFailure($coverMapping->getClassFQN()); |
||
| 99 | } |
||
| 100 | |||
| 101 | break; |
||
| 102 | |||
| 103 | case self::PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND: |
||
| 104 | case self::PHPUNIT_REFLECTION_NO_PROTECTED_METHODS_FOUND: |
||
| 105 | case self::PHPUNIT_REFLECTION_NO_PRIVATE_METHODS_FOUND: |
||
| 106 | case self::PHPUNIT_REFLECTION_NO_NOT_PUBLIC_METHODS_FOUND: |
||
| 107 | case self::PHPUNIT_REFLECTION_NO_NOT_PROTECTED_METHODS_FOUND: |
||
| 108 | View Code Duplication | case self::PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND: |
|
|
|
|||
| 109 | |||
| 110 | $coverLine = sprintf('@covers %s::<%s>', $coverMapping->getClassFQN(), $coverMapping->getAccessor()); |
||
| 111 | if (!$noAnsiColors) { |
||
| 112 | $coverLine = Color::tplNormalColor('@covers '); |
||
| 113 | $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN() . '::<'); |
||
| 114 | $coverLine .= Color::tplMarkFailure($coverMapping->getAccessor()); |
||
| 115 | $coverLine .= Color::tplYellowColor('>'); |
||
| 116 | } |
||
| 117 | |||
| 118 | break; |
||
| 119 | |||
| 120 | View Code Duplication | case self::PHPUNIT_VALIDATOR_MISSING_DEFAULT_COVER_CLASS_PROBLEM: |
|
| 121 | $coverLine = sprintf('@covers %s', $coverMapping->getClass()); |
||
| 122 | if (!$noAnsiColors) { |
||
| 123 | $coverLine = Color::tplNormalColor('@covers '); |
||
| 124 | $coverLine .= Color::tplMarkFailure($coverMapping->getClass()); |
||
| 125 | } |
||
| 126 | break; |
||
| 127 | |||
| 128 | case self::PHPUNIT_VALIDATOR_PROBLEM: |
||
| 129 | break; |
||
| 130 | |||
| 131 | default: |
||
| 132 | break; |
||
| 133 | } |
||
| 134 | |||
| 135 | return $coverLine; |
||
| 136 | } |
||
| 137 | } |
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.