Completed
Push — master ( 3b9644...b65440 )
by Zach
07:24 queued 02:31
created

CreateTextBlocksTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 36
loc 36
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

How to fix   Duplicated Code   

Duplicated Code

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
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateTextBlocksTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('text_blocks', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->string('name')->index();
19
            $table->text('text');
20
            $table->text('formatted_text');
21
            $table->integer('order');
22
            $table->integer('project_id')->nullable()->unsigned()->index();
23
            $table->timestamp('deleted_at')->nullable();
24
            $table->timestamps();
25
26
            $table->foreign('project_id')
27
              ->references('id')
28
              ->on('projects')
29
              ->onDelete('cascade');
30
        });
31
    }
32
33
    /**
34
     * Reverse the migrations.
35
     *
36
     * @return void
37
     */
38
    public function down()
39
    {
40
        Schema::dropIfExists('text_blocks');
41
    }
42
}
43