CreatePhAddressTables   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 23.21 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 13
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 7 1
A up() 13 40 1

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 CreatePhAddressTables extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16 View Code Duplication
        Schema::create('regions', function (Blueprint $table) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
            $table->increments('id');
18
            $table->string('code', 9)->unique();
19
            $table->string('name');
20
            $table->string('region_id', 2)->index();
21
        });
22
23 View Code Duplication
        Schema::create('provinces', function (Blueprint $table) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
            $table->increments('id');
25
            $table->string('code', 9)->unique();
26
            $table->string('name');
27
            $table->string('region_id', 2)->index();
28
            $table->string('province_id', 4)->index();
29
        });
30
31
        Schema::create('cities', function (Blueprint $table) {
32
            $table->increments('id');
33
            $table->string('code', 9)->unique();
34
            $table->string('name');
35
            $table->string('region_id', 2)->index();
36
            $table->string('province_id', 4)->index();
37
            $table->string('city_id', 6)->index();
38
39
            $table->index(['province_id', 'region_id'], 'cities_province_regions');
40
        });
41
42
        Schema::create('barangays', function (Blueprint $table) {
43
            $table->increments('id');
44
            $table->string('code', 9)->unique();
45
            $table->string('name');
46
            $table->string('region_id', 2)->index();
47
            $table->string('province_id', 4)->index();
48
            $table->string('city_id', 6)->index();
49
50
            $table->index(['province_id', 'region_id'], 'barangay_idx_1');
51
            $table->index(['city_id', 'province_id', 'region_id'], 'barangay_idx_2');
52
        });
53
    }
54
55
    public function down()
56
    {
57
        Schema::drop('barangays');
58
        Schema::drop('cities');
59
        Schema::drop('provinces');
60
        Schema::drop('regions');
61
    }
62
}
63