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 m180531_134500_create_about_table extends Migration |
||
9 | { |
||
10 | /** |
||
11 | * {@inheritdoc} |
||
12 | */ |
||
13 | public function safeUp() |
||
14 | { |
||
15 | $this->createTable('about', |
||
16 | [ |
||
17 | 'id' => $this->primaryKey(), |
||
18 | 'title' => $this->string(128)->notNull(), |
||
19 | 'description' => $this->text(), |
||
20 | 'content' => $this->text(), |
||
21 | 'metaKeys' => $this->string(128), |
||
22 | 'metaDescription' => $this->string(), |
||
23 | 'default' => $this->tinyInteger()->defaultValue(0), |
||
24 | 'created_at' => $this->dateTime(), |
||
25 | 'updated_at' => $this->dateTime(), |
||
26 | ] |
||
27 | ); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | public function safeDown() |
||
36 | } |
||
37 | } |
||
38 |