| Conditions | 17 | 
| Paths | 33 | 
| Total Lines | 98 | 
| Code Lines | 63 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 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  | 
            ||
| 60 | public function onMessage($msgData, $message)  | 
            ||
| 61 |     { | 
            ||
| 62 | $channelID = (int) $msgData['message']['channelID'];  | 
            ||
| 63 | |||
| 64 | if (in_array($channelID, $this->excludeChannel, true))  | 
            ||
| 65 |         { | 
            ||
| 66 | return null;  | 
            ||
| 67 | }  | 
            ||
| 68 | |||
| 69 | $this->message = $message;  | 
            ||
| 70 | |||
| 71 | $message = $msgData['message']['message'];  | 
            ||
| 72 | $user = $msgData['message']['from'];  | 
            ||
| 73 | |||
| 74 | $data = command($message, $this->information()['trigger'], $this->config['bot']['trigger']);  | 
            ||
| 75 |         if (isset($data['trigger'])) { | 
            ||
| 76 | |||
| 77 | // Most EVE players on Discord use their ingame name, so lets support @highlights  | 
            ||
| 78 |             $messageString = strstr($data['messageString'], '@') ? str_replace('<@', '', str_replace('>', '', $data['messageString'])) : $data['messageString']; | 
            ||
| 79 |             if (is_numeric($messageString)) { | 
            ||
| 80 | // The person used @highlighting, so now we got a discord id, lets map that to a name  | 
            ||
| 81 |                 $messageString = dbQueryField('SELECT name FROM usersSeen WHERE id = :id', 'name', array(':id' => $messageString)); | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | $cleanString = urlencode($messageString);  | 
            ||
| 85 | $characterID = urlencode(characterID($cleanString));  | 
            ||
| 86 | |||
| 87 |             if (empty($characterID)) { | 
            ||
| 88 |                 return $this->message->reply('**Error:** no data available'); | 
            ||
| 89 | }  | 
            ||
| 90 | |||
| 91 | //Get details  | 
            ||
| 92 | $characterDetails = characterDetails($characterID);  | 
            ||
| 93 |             if (null === $characterDetails) { | 
            ||
| 94 |                 return $this->message->reply('**Error:** ESI is down. Try again later.'); | 
            ||
| 95 | }  | 
            ||
| 96 | $corporationID = $characterDetails['corporation_id'];  | 
            ||
| 97 | $corporationName = corpName($corporationID);  | 
            ||
| 98 |             if (null === $corporationName) { | 
            ||
| 99 |                 return $this->message->reply('**Error:** ESI is down. Try again later.'); | 
            ||
| 100 | }  | 
            ||
| 101 | $corporationDetails = corpDetails($corporationID);  | 
            ||
| 102 | $allianceID = @$corporationDetails['alliance_id'];  | 
            ||
| 103 |             if (null !== $allianceID) { | 
            ||
| 104 | $allianceName = allianceName($allianceID);  | 
            ||
| 105 |             } else { | 
            ||
| 106 | $allianceName = '';  | 
            ||
| 107 | }  | 
            ||
| 108 | $characterName = $characterDetails['name'];  | 
            ||
| 109 | $dateOfBirth = $characterDetails['birthday'];  | 
            ||
| 110 | |||
| 111 |             if ($characterName === null || $characterName === '') { | 
            ||
| 112 |                 return $this->message->reply('**Error:** No character found.'); | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 115 | //ZKill lookup  | 
            ||
| 116 |             $url = "https://zkillboard.com/api/orderDirection/desc/limit/1/no-items/characterID/{$characterID}/xml/"; | 
            ||
| 117 | $xml = makeApiRequest($url);  | 
            ||
| 118 |             if (empty($xml)) { | 
            ||
| 119 |                 return $this->message->reply('**Error:** ZKill is down. Try again later.'); | 
            ||
| 120 | }  | 
            ||
| 121 |             foreach ($xml->result->rowset->row as $kill) { | 
            ||
| 122 | $lastSeenSystemID = @$kill->attributes()->solarSystemID;  | 
            ||
| 123 | $lastSeenDate = @$kill->attributes()->killTime;  | 
            ||
| 124 |                 if (null === $lastSeenSystemID || null === $lastSeenDate) { | 
            ||
| 125 | $lastSeenSystem = 'No activity reported.';  | 
            ||
| 126 | $lastSeenDate = 'No activity reported.';  | 
            ||
| 127 |                 } else { | 
            ||
| 128 | $lastSeenSystem = getSystemName($lastSeenSystemID);  | 
            ||
| 129 | }  | 
            ||
| 130 | }  | 
            ||
| 131 |             foreach ($xml->result->rowset->row->rowset->row as $attacker) { | 
            ||
| 132 |                 if ($attacker->attributes()->characterID == $characterID) { | 
            ||
| 133 | $lastSeenShipID = $attacker->attributes()->shipTypeID;  | 
            ||
| 134 | $lastSeenShip = getTypeName($lastSeenShipID);  | 
            ||
| 135 |                 } else { | 
            ||
| 136 | $lastSeenShip = 'No activity reported.';  | 
            ||
| 137 | }  | 
            ||
| 138 | }  | 
            ||
| 139 |             $url = "https://zkillboard.com/character/{$characterID}/"; | 
            ||
| 140 | |||
| 141 |             $msg = "```Name: {$characterName} | 
            ||
| 142 | DOB: {$dateOfBirth} | 
            ||
| 143 | |||
| 144 | Corporation Name: {$corporationName} | 
            ||
| 145 | Alliance Name: {$allianceName} | 
            ||
| 146 | |||
| 147 | Last Seen In System: {$lastSeenSystem} | 
            ||
| 148 | Last Seen Flying a: {$lastSeenShip} | 
            ||
| 149 | Last Seen On: {$lastSeenDate}``` | 
            ||
| 150 | |||
| 151 | For more info, visit: $url";  | 
            ||
| 152 | |||
| 153 |             $this->logger->addInfo("charInfo: Sending character info to {$user}"); | 
            ||
| 154 | $this->message->reply($msg);  | 
            ||
| 155 | }  | 
            ||
| 156 | return null;  | 
            ||
| 157 | }  | 
            ||
| 158 | |||
| 172 | 
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.