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 namespace Bedard\Shop\Updates; |
||
| 7 | View Code Duplication | class CreateOptionsTable extends Migration |
|
| 8 | { |
||
| 9 | public function up() |
||
| 10 | { |
||
| 11 | Schema::create('bedard_shop_options', function (Blueprint $table) { |
||
| 12 | $table->engine = 'InnoDB'; |
||
| 13 | $table->increments('id'); |
||
| 14 | $table->integer('product_id')->unsigned()->nullable()->index(); |
||
| 15 | $table->integer('sort_order')->unsigned()->default(0)->index(); |
||
| 16 | $table->string('name')->default(''); |
||
| 17 | $table->string('placeholder')->default(''); |
||
| 18 | $table->timestamps(); |
||
| 19 | }); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function down() |
||
| 26 | } |
||
| 27 |