for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
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:
<?php
use yii\db\Migration;
/**
* Handles the creation of table `social`.
*/
class m180602_191217_create_social_table extends Migration
{
* {@inheritdoc}
public function safeUp()
$this->createTable('social', [
'id' => $this->primaryKey(),
'icon' => $this->string(128)->notNull(),
'url' => $this->string()->notNull(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
]);
}
public function safeDown()
$this->dropTable('social');