| Conditions | 38 |
| Paths | 74 |
| Total Lines | 71 |
| Code Lines | 68 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 94 | protected function convertOddCharacter(string $c) |
||
| 95 | { |
||
| 96 | $normalizedChar = $c; |
||
| 97 | if (!is_numeric($normalizedChar)) { |
||
| 98 | $normalizedChar = strtoupper($normalizedChar); |
||
| 99 | } |
||
| 100 | switch ($normalizedChar) { |
||
| 101 | case '0': |
||
| 102 | case 'A': |
||
| 103 | return 1; |
||
| 104 | case '1': |
||
| 105 | case 'B': |
||
| 106 | return 0; |
||
| 107 | case '2': |
||
| 108 | case 'C': |
||
| 109 | return 5; |
||
| 110 | case '3': |
||
| 111 | case 'D': |
||
| 112 | return 7; |
||
| 113 | case '4': |
||
| 114 | case 'E': |
||
| 115 | return 9; |
||
| 116 | case '5': |
||
| 117 | case 'F': |
||
| 118 | return 13; |
||
| 119 | case '6': |
||
| 120 | case 'G': |
||
| 121 | return 15; |
||
| 122 | case '7': |
||
| 123 | case 'H': |
||
| 124 | return 17; |
||
| 125 | case '8': |
||
| 126 | case 'I': |
||
| 127 | return 19; |
||
| 128 | case '9': |
||
| 129 | case 'J': |
||
| 130 | return 21; |
||
| 131 | case 'K': |
||
| 132 | return 2; |
||
| 133 | case 'L': |
||
| 134 | return 4; |
||
| 135 | case 'M': |
||
| 136 | return 18; |
||
| 137 | case 'N': |
||
| 138 | return 20; |
||
| 139 | case 'O': |
||
| 140 | return 11; |
||
| 141 | case 'P': |
||
| 142 | return 3; |
||
| 143 | case 'Q': |
||
| 144 | return 6; |
||
| 145 | case 'R': |
||
| 146 | return 8; |
||
| 147 | case 'S': |
||
| 148 | return 12; |
||
| 149 | case 'T': |
||
| 150 | return 14; |
||
| 151 | case 'U': |
||
| 152 | return 16; |
||
| 153 | case 'V': |
||
| 154 | return 10; |
||
| 155 | case 'W': |
||
| 156 | return 22; |
||
| 157 | case 'X': |
||
| 158 | return 25; |
||
| 159 | case 'Y': |
||
| 160 | return 24; |
||
| 161 | case 'Z': |
||
| 162 | return 23; |
||
| 163 | default: |
||
| 164 | return -1; |
||
| 165 | } |
||
| 253 |