Passed
Push — main ( 84e8a4...ccca22 )
by Andrey
03:59
created

Migrationable::changeTable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
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
    public function __construct()
16
    {
17
        $this->connection = config('short_url.connection');
18
19
        $this->table = config('short_url.table', 'shorts');
20
    }
21
22
    protected function createTable(Closure $callback): void
23
    {
24
        $this->tableConnection()->create($this->table, $callback);
25
    }
26
27
    protected function tableConnection(): Builder
28
    {
29
        return Schema::connection($this->connection);
30
    }
31
}
32