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 declare(strict_types=1); |
||
29 | class FileSeedRunner extends BaseSeedRunner |
||
30 | { |
||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $seedsPath; |
||
35 | |||
36 | /** |
||
37 | * @var string[] |
||
38 | */ |
||
39 | private $seedClasses; |
||
40 | |||
41 | /** |
||
42 | * @param IoInterface $inOut |
||
43 | * @param string $seedsPath |
||
44 | 2 | * @param callable|null $seedInit |
|
45 | * @param string $seedsTable |
||
46 | */ |
||
47 | public function __construct( |
||
57 | |||
58 | 1 | /** |
|
59 | * @inheritdoc |
||
60 | */ |
||
61 | 1 | View Code Duplication | public function run(ContainerInterface $container): void |
78 | |||
79 | /** |
||
80 | * @param string[] $seedClasses |
||
81 | 1 | * |
|
82 | * @return self |
||
83 | 1 | */ |
|
84 | private function setSeedClasses(array $seedClasses): self |
||
90 | |||
91 | 1 | /** |
|
92 | * @inheritdoc |
||
93 | 1 | */ |
|
94 | protected function getSeedClasses(): array |
||
98 | |||
99 | 1 | /** |
|
100 | * @return string |
||
101 | 1 | */ |
|
102 | protected function getSeedsPath(): string |
||
106 | |||
107 | /** |
||
108 | * @param string $seedsPath |
||
109 | 2 | * |
|
110 | * @return self |
||
111 | 2 | */ |
|
112 | protected function setSeedsPath(string $seedsPath): self |
||
118 | } |
||
119 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.