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 |
||
26 | class Config |
||
27 | { |
||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $formatters = []; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $handlers = []; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $processors = []; |
||
42 | |||
43 | /** |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $channels = []; |
||
47 | |||
48 | /** |
||
49 | * Config constructor. |
||
50 | * |
||
51 | * @param array $config |
||
52 | */ |
||
53 | public function __construct(array $config) |
||
57 | |||
58 | /** |
||
59 | * @param string $name |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | public function getChannel(string $name) |
||
74 | |||
75 | /** |
||
76 | * @param array $names |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | protected function getFormatters(array $names) |
||
86 | |||
87 | /** |
||
88 | * @param array $names |
||
89 | * |
||
90 | * @return array |
||
91 | */ |
||
92 | protected function getHandlers(array $names) |
||
98 | |||
99 | /** |
||
100 | * @param array $names |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | protected function getProcessors(array $names) |
||
110 | |||
111 | /** |
||
112 | * @param string $formatterId |
||
113 | * |
||
114 | * @return \Monolog\Formatter\FormatterInterface |
||
115 | */ |
||
116 | protected function getFormatter(string $formatterId) |
||
126 | |||
127 | /** |
||
128 | * @param string $handlerId |
||
129 | * |
||
130 | * @return \Monolog\Handler\HandlerInterface |
||
131 | */ |
||
132 | protected function getHandler(string $handlerId) |
||
140 | |||
141 | /** |
||
142 | * @param string $processorId |
||
143 | * |
||
144 | * @return \Monolog\Handler\HandlerInterface |
||
145 | */ |
||
146 | protected function getProcessor(string $processorId) |
||
154 | |||
155 | /** |
||
156 | * @param array $config |
||
157 | */ |
||
158 | protected function parse(array $config): void |
||
165 | |||
166 | /** |
||
167 | * @param array $formatters |
||
168 | * |
||
169 | * @return array |
||
170 | */ |
||
171 | View Code Duplication | protected function formatFormatters(array $formatters = []) |
|
184 | |||
185 | /** |
||
186 | * @param array $handlers |
||
187 | * |
||
188 | * @return array |
||
189 | */ |
||
190 | protected function formatHandlers(array $handlers = []) |
||
223 | |||
224 | /** |
||
225 | * @param array $processors |
||
226 | * |
||
227 | * @return array |
||
228 | */ |
||
229 | View Code Duplication | protected function formatProcessors(array $processors = []) |
|
246 | |||
247 | /** |
||
248 | * @param array $channels |
||
249 | * |
||
250 | * @return array |
||
251 | */ |
||
252 | protected function formatChannels(array $channels = []) |
||
271 | } |
||
272 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.