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 |
||
13 | class Version20151119082400 extends AbstractMigrationChamilo |
||
14 | { |
||
15 | /** |
||
16 | * @param Schema $schema |
||
17 | */ |
||
18 | public function up(Schema $schema) |
||
19 | { |
||
20 | $user = $schema->getTable('user'); |
||
21 | $user->addIndex(['user_id']); |
||
22 | |||
23 | $userRelTag = $schema->getTable('user_rel_tag'); |
||
24 | $userRelTag->addIndex(['user_id']); |
||
25 | $userRelTag->addIndex(['tag_id']); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param Schema $schema |
||
30 | */ |
||
31 | public function down(Schema $schema) |
||
32 | { |
||
33 | } |
||
34 | } |
||
35 |