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 |
||
30 | final class Definition implements DefinitionInterface |
||
31 | { |
||
32 | /** @var VersionId */ |
||
33 | private $id; |
||
34 | |||
35 | /** @var MigrationInterface */ |
||
36 | private $migration; |
||
37 | |||
38 | /** |
||
39 | * Definition constructor. |
||
40 | * @param MigrationInterface $migration |
||
41 | * @param null|string|ValueObjectInterface $id Overrides the ID for the migration with the specified ID |
||
42 | */ |
||
43 | 8 | View Code Duplication | public function __construct(MigrationInterface $migration, $id = null) |
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | 3 | public function getId() |
|
62 | |||
63 | /** |
||
64 | * @return MigrationInterface |
||
65 | */ |
||
66 | 2 | public function getMigration() |
|
70 | } |
||
71 |