CountryMigration::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 2
rs 9.9332
c 0
b 0
f 0
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
}