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 |
||
39 | class DebugUtil implements DebugUtilInterface |
||
40 | { |
||
41 | |||
42 | /** |
||
43 | * The trait that provides basic system logger functionality. |
||
44 | * |
||
45 | * @var \TechDivision\Import\SystemLoggerTrait |
||
46 | */ |
||
47 | use SystemLoggerTrait; |
||
48 | |||
49 | /** |
||
50 | * The import processor instance. |
||
51 | * |
||
52 | * @var \TechDivision\Import\Services\RegistryProcessorInterface |
||
53 | */ |
||
54 | private $registryProcessor; |
||
55 | |||
56 | /** |
||
57 | * The configuration instance. |
||
58 | * |
||
59 | * @var \TechDivision\Import\Configuration\ConfigurationInterface |
||
60 | */ |
||
61 | private $configuration; |
||
62 | |||
63 | /** |
||
64 | * The debug dump renderer. |
||
65 | * |
||
66 | * @var \TechDivision\Import\Listeners\Renderer\RendererInterface |
||
67 | */ |
||
68 | private $renderer; |
||
69 | |||
70 | /** |
||
71 | * Initializes the plugin with the application instance. |
||
72 | * |
||
73 | * @param \TechDivision\Import\Services\RegistryProcessorInterface $registryProcessor The registry processor instance |
||
74 | * @param \TechDivision\Import\Configuration\ConfigurationInterface $configuration The configuration instance |
||
75 | * @param \Doctrine\Common\Collections\Collection $systemLoggers The array with the system loggers instances |
||
76 | * @param \TechDivision\Import\Listeners\Renderer\RendererInterface $renderer The debug dump renderer instance |
||
77 | */ |
||
78 | public function __construct( |
||
90 | |||
91 | /** |
||
92 | * Return's the registry processor instance. |
||
93 | * |
||
94 | * @return \TechDivision\Import\Services\RegistryProcessorInterface The registry processor instance |
||
95 | */ |
||
96 | private function getRegistryProcessor() : RegistryProcessorInterface |
||
100 | |||
101 | /** |
||
102 | * Return's the configuration instance. |
||
103 | * |
||
104 | * @return \TechDivision\Import\Configuration\ConfigurationInterface The configuration instance |
||
105 | */ |
||
106 | private function getConfiguration() : ConfigurationInterface |
||
110 | |||
111 | /** |
||
112 | * Return's the application instance. |
||
113 | * |
||
114 | * @return \TechDivision\Import\ApplicationInterface The application instance |
||
115 | */ |
||
116 | private function getApplication() : ApplicationInterface |
||
120 | |||
121 | /** |
||
122 | * Return's the debug dump renderer instance. |
||
123 | * |
||
124 | * @return \TechDivision\Import\Listeners\Renderer\RendererInterface The debug dump renderer instance |
||
125 | */ |
||
126 | private function getRenderer() : RendererInterface |
||
130 | |||
131 | /** |
||
132 | * The method to extract an archive that has already been created by a previous |
||
133 | * import back into the source directory. |
||
134 | * |
||
135 | * @param string $serial The serial of the archive to extract |
||
136 | * |
||
137 | * @return void |
||
138 | * @throws \Exception Is thrown, if the archive can not be extracted back into the source directory |
||
139 | */ |
||
140 | public function extractArchive(string $serial) : void |
||
201 | |||
202 | /** |
||
203 | * The method to create the debugging artefacts in the apropriate directory. |
||
204 | * |
||
205 | * @param string $serial The serial to prepare the dump for |
||
206 | * |
||
207 | * @return void |
||
208 | * @throws \Exception Is thrown, if the configuration can not be dumped |
||
209 | */ |
||
210 | View Code Duplication | public function prepareDump(string $serial) : void |
|
230 | |||
231 | /** |
||
232 | * The method to create the debug dump with all artefacts and reports. |
||
233 | * |
||
234 | * @param string $serial The serial to create the dump for |
||
235 | * |
||
236 | * @return string $filename The name of the dumpfile |
||
237 | * @throws \InvalidArgumentException Is thrown, if the passed serial has no matching import to create the dump for |
||
238 | */ |
||
239 | public function createDump(string $serial) : string |
||
280 | } |
||
281 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..