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 |
||
8 | class m180220_083639_create_albums_table extends Migration |
||
9 | { |
||
10 | /** |
||
11 | * {@inheritdoc} |
||
12 | */ |
||
13 | public function safeUp() |
||
14 | { |
||
15 | $this->createTable('albums', [ |
||
16 | 'id' => $this->primaryKey(), |
||
|
|||
17 | 'title' => $this->string(64)->notNull(), |
||
18 | 'description' => $this->text(), |
||
19 | 'type' => $this->string(64)->notNull(), |
||
20 | 'created_at' => $this->integer()->notNull(), |
||
21 | 'updated_at' => $this->integer(), |
||
22 | ]); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | public function safeDown() |
||
31 | } |
||
32 | } |
||
33 |