Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 9 | class MonologHandlerFactory |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Returns an instance of \Monolog\Handler\HandlerInterface |
||
| 13 | * @param string $name Then name of the handler you want to create |
||
| 14 | * @param array $config An array of config values to use |
||
| 15 | * @param string $title |
||
| 16 | * @return \Monolog\Handler\HandlerInterface |
||
| 17 | */ |
||
| 18 | 33 | public static function create($name, array $config = [], $title = null){ |
|
| 21 | |||
| 22 | /** |
||
| 23 | * Returns a PushoverHandler |
||
| 24 | * @param array $config An array of config values to use |
||
| 25 | * @param string $title The title/subject to use |
||
| 26 | * @return \Monolog\Handler\PushoverHandler |
||
| 27 | */ |
||
| 28 | 9 | protected static function pushover(array $config = [], $title = null){ |
|
| 56 | |||
| 57 | /** |
||
| 58 | * Returns a FlowdockHandler |
||
| 59 | * @param array $config An array of config values to use |
||
| 60 | * @param string $title The title/subject to use |
||
| 61 | * @return \Monolog\Handler\FlowdockHandler |
||
| 62 | */ |
||
| 63 | 3 | View Code Duplication | protected static function flowdock(array $config = [], $title = null){ |
| 76 | |||
| 77 | /** |
||
| 78 | * Returns a FleepHookHandler |
||
| 79 | * @param array $config An array of config values to use |
||
| 80 | * @param string $title The title/subject to use |
||
| 81 | * @return \Monolog\Handler\FleepHookHandler |
||
| 82 | */ |
||
| 83 | 3 | View Code Duplication | protected static function fleephook(array $config = [], $title = null){ |
| 96 | |||
| 97 | /** |
||
| 98 | * Returns a PlivoHandler |
||
| 99 | * @param array $config An array of config values to use |
||
| 100 | * @param string $title The title/subject to use |
||
| 101 | * @return \Tylercd100\Monolog\Handler\PlivoHandler |
||
| 102 | */ |
||
| 103 | 3 | View Code Duplication | protected static function plivo(array $config = [], $title = null){ |
| 125 | |||
| 126 | /** |
||
| 127 | * Returns a TwilioHandler |
||
| 128 | * @param array $config An array of config values to use |
||
| 129 | * @param string $title The title/subject to use |
||
| 130 | * @return \Tylercd100\Monolog\Handler\TwilioHandler |
||
| 131 | */ |
||
| 132 | 3 | View Code Duplication | protected static function twilio(array $config = [], $title = null){ |
| 154 | |||
| 155 | /** |
||
| 156 | * Returns a SlackHandler |
||
| 157 | * @param array $config An array of config values to use |
||
| 158 | * @param string $title The title/subject to use |
||
| 159 | * @return \Monolog\Handler\SlackHandler |
||
| 160 | */ |
||
| 161 | 9 | protected static function slack(array $config = [], $title = null){ |
|
| 185 | |||
| 186 | /** |
||
| 187 | * Returns a HipChatHandler |
||
| 188 | * @param array $config An array of config values to use |
||
| 189 | * @param string $title The title/subject to use |
||
| 190 | * @return \Monolog\Handler\HipChatHandler |
||
| 191 | */ |
||
| 192 | 9 | protected static function hipchat(array $config = [], $title = null){ |
|
| 218 | |||
| 219 | /** |
||
| 220 | * Creates Mail Monolog Handler |
||
| 221 | * @param array $config An array of config values to use |
||
| 222 | * @param string $title The title/subject to use |
||
| 223 | * @return \Monolog\Handler\MailHandler |
||
| 224 | */ |
||
| 225 | 6 | protected static function mail(array $config = [], $title = null) |
|
| 233 | |||
| 234 | /** |
||
| 235 | * Creates Mail Monolog Handler |
||
| 236 | * @param array $config An array of config values to use |
||
| 237 | * @param string $title The title/subject to use |
||
| 238 | * @return \Monolog\Handler\SwiftMailerHandler |
||
| 239 | */ |
||
| 240 | 3 | protected static function swiftMail(array $config, $title = null) |
|
| 258 | |||
| 259 | /** |
||
| 260 | * Creates Mail Monolog Handler |
||
| 261 | * @param array $config An array of config values to use |
||
| 262 | * @param string $title The title/subject to use |
||
| 263 | * @return \Monolog\Handler\NativeMailerHandler |
||
| 264 | */ |
||
| 265 | 3 | protected static function nativeMail(array $config, $title = null) |
|
| 286 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.