Migrationable::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Helldar\ShortUrl\Conrerns;
4
5
use Closure;
6
use Illuminate\Database\Schema\Builder;
7
use Illuminate\Support\Facades\Schema;
8
9
trait Migrationable
10
{
11
    protected $connection;
12
13
    protected $table;
14
15 8
    public function __construct()
16
    {
17 8
        $this->connection = config('short_url.connection');
18
19 8
        $this->table = config('short_url.table', 'shorts');
20 8
    }
21
22 8
    protected function createTable(Closure $callback): void
23
    {
24 8
        $this->tableConnection()->create($this->table, $callback);
25 8
    }
26
27 8
    protected function tableConnection(): Builder
28
    {
29 8
        return Schema::connection($this->connection);
30
    }
31
}
32