Migrationable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
ccs 9
cts 9
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createTable() 0 3 1
A tableConnection() 0 3 1
A __construct() 0 5 1
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