| Conditions | 10 |
| Paths | 272 |
| Total Lines | 25 |
| Code Lines | 15 |
| 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 |
||
| 58 | private static function getDestinations($kill) |
||
| 59 | { |
||
| 60 | $kill = json_decode($kill, true); |
||
| 61 | $destinations = array(); |
||
| 62 | |||
| 63 | $destinations[] = "/topic/kills"; |
||
| 64 | $destinations[] = "/topic/location.solarsystem.".$kill["solarSystemID"]; |
||
| 65 | |||
| 66 | // victim |
||
| 67 | if($kill["victim"]["characterID"] > 0) $destinations[] = "/topic/involved.character.".$kill["victim"]["characterID"]; |
||
| 68 | if($kill["victim"]["corporationID"] > 0) $destinations[] = "/topic/involved.corporation.".$kill["victim"]["corporationID"]; |
||
| 69 | if($kill["victim"]["factionID"] > 0) $destinations[] = "/topic/involved.faction.".$kill["victim"]["factionID"]; |
||
| 70 | if($kill["victim"]["allianceID"] > 0) $destinations[] = "/topic/involved.alliance.".$kill["victim"]["allianceID"]; |
||
| 71 | |||
| 72 | // attackers |
||
| 73 | foreach($kill["attackers"] as $attacker) |
||
| 74 | { |
||
| 75 | if($attacker["characterID"] > 0) $destinations[] = "/topic/involved.character." . $attacker["characterID"]; |
||
| 76 | if($attacker["corporationID"] > 0) $destinations[] = "/topic/involved.corporation." . $attacker["corporationID"]; |
||
| 77 | if($attacker["factionID"] > 0) $destinations[] = "/topic/involved.faction." . $attacker["factionID"]; |
||
| 78 | if($attacker["allianceID"] > 0) $destinations[] = "/topic/involved.alliance." . $attacker["allianceID"]; |
||
| 79 | } |
||
| 80 | |||
| 81 | return $destinations; |
||
| 82 | } |
||
| 83 | } |
||
| 84 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.