CountryMigration   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 1
A check() 0 7 2
A down() 0 4 1
1
<?php
2
namespace agoalofalife\database\migrations;
3
4
use agoalofalife\Contracts\Checker;
5
use agoalofalife\Contracts\ContractMigration;
6
use \Illuminate\Database\Capsule\Manager as Capsule;
7
8
class CountryMigration implements ContractMigration, Checker
9
{
10
    public function execute()
11
    {
12
        Capsule::schema()->create('country', function ($table) {
13
            $table->increments('id');
14
            $table->string('title', 100);
15
            $table->string('code')->nullable()->comments('unique value');
16
            $table->text('description')->nullable();
17
            $table->timestamps();
18
        });
19
    }
20
21
    public function check(callable $callback)
22
    {
23
        if ( Capsule::schema()->hasTable('country') === false )
24
        {
25
            call_user_func($callback, $this);
26
        }
27
    }
28
29
    /**
30
     * Reverse the migrations.
31
     *
32
     * @return void
33
     */
34
    public function down()
35
    {
36
        Capsule::schema()->dropIfExists('country');
37
    }
38
}