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){ |
127 | |||
128 | /** |
||
129 | * Returns a TwilioHandler |
||
130 | * @param array $config An array of config values to use |
||
131 | * @param string $title The title/subject to use |
||
132 | * @return \Tylercd100\Monolog\Handler\TwilioHandler |
||
133 | */ |
||
134 | 3 | View Code Duplication | protected static function twilio(array $config = [], $title = null){ |
158 | |||
159 | /** |
||
160 | * Returns a SlackHandler |
||
161 | * @param array $config An array of config values to use |
||
162 | * @param string $title The title/subject to use |
||
163 | * @return \Monolog\Handler\SlackHandler |
||
164 | */ |
||
165 | 9 | protected static function slack(array $config = [], $title = null){ |
|
189 | |||
190 | /** |
||
191 | * Returns a HipChatHandler |
||
192 | * @param array $config An array of config values to use |
||
193 | * @param string $title The title/subject to use |
||
194 | * @return \Monolog\Handler\HipChatHandler |
||
195 | */ |
||
196 | 9 | protected static function hipchat(array $config = [], $title = null){ |
|
222 | |||
223 | /** |
||
224 | * Creates Mail Monolog Handler |
||
225 | * @param array $config An array of config values to use |
||
226 | * @param string $title The title/subject to use |
||
227 | * @return \Monolog\Handler\MailHandler |
||
228 | */ |
||
229 | 6 | protected static function mail(array $config = [], $title = null) |
|
237 | |||
238 | /** |
||
239 | * Creates Mail Monolog Handler |
||
240 | * @param array $config An array of config values to use |
||
241 | * @param string $title The title/subject to use |
||
242 | * @return \Monolog\Handler\SwiftMailerHandler |
||
243 | */ |
||
244 | 3 | protected static function swiftMail(array $config, $title = null) |
|
262 | |||
263 | /** |
||
264 | * Creates Mail Monolog Handler |
||
265 | * @param array $config An array of config values to use |
||
266 | * @param string $title The title/subject to use |
||
267 | * @return \Monolog\Handler\NativeMailerHandler |
||
268 | */ |
||
269 | 3 | protected static function nativeMail(array $config, $title = null) |
|
290 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.