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( |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Return's the registry processor instance. |
||
| 92 | * |
||
| 93 | * @return \TechDivision\Import\Services\RegistryProcessorInterface The registry processor instance |
||
| 94 | */ |
||
| 95 | private function getRegistryProcessor() : RegistryProcessorInterface |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Return's the configuration instance. |
||
| 102 | * |
||
| 103 | * @return \TechDivision\Import\Configuration\ConfigurationInterface The configuration instance |
||
| 104 | */ |
||
| 105 | private function getConfiguration() : ConfigurationInterface |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Return's the debug dump renderer instance. |
||
| 112 | * |
||
| 113 | * @return \TechDivision\Import\Listeners\Renderer\RendererInterface The debug dump renderer instance |
||
| 114 | */ |
||
| 115 | private function getRenderer() : RendererInterface |
||
| 119 | |||
| 120 | /** |
||
| 121 | * The method to extract an archive that has already been created by a previous |
||
| 122 | * import back into the source directory. |
||
| 123 | * |
||
| 124 | * @param string $serial The serial of the archive to extract |
||
| 125 | * |
||
| 126 | * @return void |
||
| 127 | * @throws \Exception Is thrown, if the archive can not be extracted back into the source directory |
||
| 128 | */ |
||
| 129 | public function extractArchive(string $serial) : void |
||
| 190 | |||
| 191 | /** |
||
| 192 | * The method to create the debugging artefacts in the appropriate directory. |
||
| 193 | * |
||
| 194 | * @param string $serial The serial to prepare the dump for |
||
| 195 | * |
||
| 196 | * @return void |
||
| 197 | * @throws \Exception Is thrown, if the configuration can not be dumped |
||
| 198 | */ |
||
| 199 | View Code Duplication | public function prepareDump(string $serial) : void |
|
| 219 | |||
| 220 | /** |
||
| 221 | * The method to create the debug dump with all artefacts and reports. |
||
| 222 | * |
||
| 223 | * @param string $serial The serial to create the dump for |
||
| 224 | * |
||
| 225 | * @return string $filename The name of the dumpfile |
||
| 226 | * @throws \InvalidArgumentException Is thrown, if the passed serial has no matching import to create the dump for |
||
| 227 | */ |
||
| 228 | public function createDump(string $serial) : string |
||
| 269 | } |
||
| 270 |
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..