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 | 27 | 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 PlivoHandler |
||
59 | * @param array $config An array of config values to use |
||
60 | * @param string $title The title/subject to use |
||
61 | * @return \Tylercd100\Monolog\Handler\PlivoHandler |
||
62 | */ |
||
63 | View Code Duplication | protected static function plivo(array $config = [], $title = null){ |
|
85 | |||
86 | /** |
||
87 | * Returns a TwilioHandler |
||
88 | * @param array $config An array of config values to use |
||
89 | * @param string $title The title/subject to use |
||
90 | * @return \Tylercd100\Monolog\Handler\TwilioHandler |
||
91 | */ |
||
92 | 6 | View Code Duplication | protected static function twilio(array $config = [], $title = null){ |
114 | |||
115 | /** |
||
116 | * Returns a SlackHandler |
||
117 | * @param array $config An array of config values to use |
||
118 | * @param string $title The title/subject to use |
||
119 | * @return \Monolog\Handler\SlackHandler |
||
120 | */ |
||
121 | 9 | protected static function slack(array $config = [], $title = null){ |
|
145 | |||
146 | /** |
||
147 | * Returns a HipChatHandler |
||
148 | * @param array $config An array of config values to use |
||
149 | * @param string $title The title/subject to use |
||
150 | * @return \Monolog\Handler\HipChatHandler |
||
151 | */ |
||
152 | 9 | protected static function hipchat(array $config = [], $title = null){ |
|
178 | |||
179 | /** |
||
180 | * Creates Mail Monolog Handler |
||
181 | * @param array $config An array of config values to use |
||
182 | * @param string $title The title/subject to use |
||
183 | * @return \Monolog\Handler\MailHandler |
||
184 | */ |
||
185 | 6 | protected static function mail(array $config = [], $title = null) |
|
193 | |||
194 | /** |
||
195 | * Creates Mail Monolog Handler |
||
196 | * @param array $config An array of config values to use |
||
197 | * @param string $title The title/subject to use |
||
198 | * @return \Monolog\Handler\SwiftMailerHandler |
||
199 | */ |
||
200 | 3 | protected static function swiftMail(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\NativeMailerHandler |
||
224 | */ |
||
225 | 3 | protected static function nativeMail(array $config, $title = null) |
|
246 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.