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 |
||
12 | class Version20151101082200 extends AbstractMigrationChamilo |
||
13 | { |
||
14 | /** |
||
15 | * @param Schema $schema |
||
16 | */ |
||
17 | public function up(Schema $schema) |
||
18 | { |
||
19 | $this->addSql("ALTER TABLE access_url ENGINE=InnoDB"); |
||
20 | $this->addSql("ALTER TABLE access_url_rel_course ENGINE=InnoDB"); |
||
21 | $this->addSql("ALTER TABLE course_rel_user ENGINE=InnoDB"); |
||
22 | $this->addSql("ALTER TABLE session_category ENGINE=InnoDB"); |
||
23 | $this->addSql("ALTER TABLE settings_current ENGINE=InnoDB"); |
||
24 | $this->addSql("ALTER TABLE settings_options ENGINE=InnoDB"); |
||
25 | $this->addSql("ALTER TABLE usergroup ENGINE=InnoDB"); |
||
26 | $this->addSql("ALTER TABLE usergroup_rel_user ENGINE=InnoDB"); |
||
27 | |||
28 | $this->addSql("ALTER TABLE session_rel_course DROP PRIMARY KEY"); |
||
29 | $this->addSql("ALTER TABLE session_rel_course_rel_user DROP PRIMARY KEY"); |
||
30 | $this->addSql("ALTER TABLE session MODIFY session_category_id INT NULL"); |
||
31 | |||
32 | $this->addSql("UPDATE session SET session_category_id = NULL WHERE session_category_id = 0"); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param Schema $schema |
||
37 | */ |
||
38 | public function down(Schema $schema) |
||
39 | { |
||
40 | } |
||
41 | } |
||
42 |