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_170328_create_technologies_table extends Migration |
||
9 | { |
||
10 | /** |
||
11 | * {@inheritdoc} |
||
12 | */ |
||
13 | public function safeUp() |
||
14 | { |
||
15 | $this->createTable('technologies', [ |
||
16 | 'id' => $this->primaryKey(), |
||
17 | 'name' => $this->string(128)->notNull(), |
||
18 | 'share' => $this->tinyInteger(), |
||
19 | 'icon' => $this->string(128), |
||
20 | 'created_at' => $this->dateTime(), |
||
21 | 'updated_at' => $this->dateTime(), |
||
22 | ]); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | public function safeDown() |
||
31 | } |
||
32 | } |
||
33 |