| Conditions | 10 |
| Paths | 10 |
| Total Lines | 35 |
| Code Lines | 30 |
| 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 |
||
| 107 | protected function findCompatibleRedBloodCellGroup(string $bloodGroup) |
||
| 108 | { |
||
| 109 | $compatibleGroups = []; |
||
| 110 | |||
| 111 | switch ($bloodGroup) { |
||
| 112 | case 'A+': |
||
| 113 | $compatibleGroups = ['A+', 'A-', 'O+', 'O-']; |
||
| 114 | break; |
||
| 115 | case 'A-': |
||
| 116 | $compatibleGroups = ['A-', 'O-']; |
||
| 117 | break; |
||
| 118 | case 'B+': |
||
| 119 | $compatibleGroups = ['B+', 'B-', 'O+', 'O-']; |
||
| 120 | break; |
||
| 121 | case 'B+': |
||
| 122 | $compatibleGroups = ['B+', 'B-', 'O+', 'O-']; |
||
| 123 | break; |
||
| 124 | case 'B-': |
||
| 125 | $compatibleGroups = ['B-', 'O-']; |
||
| 126 | break; |
||
| 127 | case 'O+': |
||
| 128 | $compatibleGroups = ['O+', 'O-']; |
||
| 129 | break; |
||
| 130 | case 'O-': |
||
| 131 | $compatibleGroups = ['O-']; |
||
| 132 | break; |
||
| 133 | case 'AB+': |
||
| 134 | $compatibleGroups = ['any']; |
||
| 135 | break; |
||
| 136 | case 'AB-': |
||
| 137 | $compatibleGroups = ['A-', 'B-', 'O-', 'AB-']; |
||
| 138 | break; |
||
| 139 | } |
||
| 140 | |||
| 141 | return $compatibleGroups; |
||
| 142 | } |
||
| 144 |