| Conditions | 5 | 
| Paths | 1 | 
| Total Lines | 64 | 
| Code Lines | 47 | 
| 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 | ||
| 154 | protected function defaultSubstitutions() | ||
| 155 |     { | ||
| 156 | return [ | ||
| 157 | 'levelAndRequest' => [ | ||
| 158 | 'title' => null, | ||
| 159 | 'short' => false, | ||
| 160 | 'wrapAsCode' => false, | ||
| 161 |                 'value' => function (Message $message) { | ||
| 162 |                     if (isset($this->levelEmojis[$message->message[1]])) { | ||
| 163 | $value = $this->levelEmojis[$message->message[1]] . ' '; | ||
| 164 |                     } else { | ||
| 165 | $value = '*' . ucfirst($message->getLevel()) . '* @ '; | ||
| 166 | } | ||
| 167 |                     if ($message->getIsConsoleRequest()) { | ||
| 168 | $value .= '`' . $message->getCommandLine() . '`'; | ||
| 169 |                     } else { | ||
| 170 |                         $value .= '[' . $message->getUrl() . '](' . $message->getUrl() . ')'; | ||
| 171 | } | ||
| 172 | return $value; | ||
| 173 | }, | ||
| 174 | ], | ||
| 175 | 'category' => [ | ||
| 176 | 'emojiTitle' => '📖', | ||
| 177 | 'short' => true, | ||
| 178 | 'wrapAsCode' => false, | ||
| 179 |                 'value' => function (Message $message) { | ||
| 180 | return '`' . $message->getCategory() . '`'; | ||
| 181 | }, | ||
| 182 | ], | ||
| 183 | 'user' => [ | ||
| 184 | 'emojiTitle' => '🙂', | ||
| 185 | 'short' => true, | ||
| 186 | 'wrapAsCode' => false, | ||
| 187 |                 'value' => function (Message $message) { | ||
| 188 | $value = []; | ||
| 189 | $ip = $message->getUserIp(); | ||
| 190 |                     if ((string) $ip !== '') { | ||
| 191 | $value[] = $ip; | ||
| 192 | } | ||
| 193 | $id = $message->getUserId(); | ||
| 194 |                     if ((string) $id !== '') { | ||
| 195 |                         $value[] = "ID: `{$id}`"; | ||
| 196 | } | ||
| 197 |                     return implode(str_repeat(' ', 4), $value); | ||
| 198 | }, | ||
| 199 | ], | ||
| 200 | 'stackTrace' => [ | ||
| 201 | 'title' => 'Stack Trace', | ||
| 202 | 'short' => false, | ||
| 203 | 'wrapAsCode' => true, | ||
| 204 |                 'value' => function (Message $message) { | ||
| 205 | return $message->getStackTrace(); | ||
| 206 | }, | ||
| 207 | ], | ||
| 208 | 'text' => [ | ||
| 209 | 'title' => null, | ||
| 210 | 'short' => false, | ||
| 211 | 'wrapAsCode' => true, | ||
| 212 |                 'value' => function (Message $message) { | ||
| 213 | return $message->getText(); | ||
| 214 | }, | ||
| 215 | ], | ||
| 216 | ]; | ||
| 217 | } | ||
| 218 | |||
| 249 |