| Conditions | 5 |
| Paths | 4 |
| Total Lines | 55 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 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 |
||
| 44 | public function getErrorList($testFile) |
||
| 45 | { |
||
| 46 | switch ($testFile) { |
||
| 47 | case 'InlineCommentUnitTest.inc': |
||
| 48 | $errors = array( |
||
| 49 | 17 => 1, |
||
| 50 | 27 => 1, |
||
| 51 | 28 => 1, |
||
| 52 | 32 => 2, |
||
| 53 | 36 => 1, |
||
| 54 | 44 => 2, |
||
| 55 | 54 => 1, |
||
| 56 | 58 => 1, |
||
| 57 | 61 => 1, |
||
| 58 | 64 => 2, |
||
| 59 | 67 => 1, |
||
| 60 | 95 => 1, |
||
| 61 | 96 => 1, |
||
| 62 | 97 => 2, |
||
| 63 | // The @var inline comments are allowed. |
||
| 64 | 118 => 0, |
||
| 65 | 130 => 1, |
||
| 66 | 133 => 1, |
||
| 67 | 156 => 1, |
||
| 68 | // Comments starting with non-letter are allowed. |
||
| 69 | 159 => 0, |
||
| 70 | 162 => 0, |
||
| 71 | ); |
||
| 72 | |||
| 73 | // Before PHPCS 2.4.0 traits were not tokenized below PHP 5.4. |
||
| 74 | if (version_compare(PHP_CodeSniffer::VERSION, '2.4.0', '<') && version_compare(PHP_VERSION, '5.4.0', '<')) { |
||
| 75 | $errors[106] = 1; |
||
| 76 | } |
||
| 77 | return $errors; |
||
| 78 | |||
| 79 | case 'InlineCommentUnitTest.js': |
||
| 80 | return array( |
||
| 81 | 31 => 1, |
||
| 82 | 36 => 2, |
||
| 83 | 44 => 1, |
||
| 84 | 48 => 1, |
||
| 85 | 51 => 1, |
||
| 86 | 54 => 2, |
||
| 87 | 57 => 1, |
||
| 88 | 102 => 1, |
||
| 89 | 103 => 1, |
||
| 90 | 104 => 3, |
||
| 91 | // Comments starting with digit are allowed. |
||
| 92 | 113 => 0, |
||
| 93 | ); |
||
| 94 | }//end switch |
||
| 95 | |||
| 96 | return array(); |
||
| 97 | |||
| 98 | }//end getErrorList() |
||
| 99 | |||
| 119 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.