GetAttribute   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 19
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAutoIncrement() 0 6 1
A getMysqlAutoIncrement() 0 4 1
A getSqliteAutoIncrement() 0 4 1
1
<?php
2
3
namespace Sausin\DBSetAutoIncrement;
4
5
use Illuminate\Support\Facades\DB;
6
7
trait GetAttribute
8
{
9
    protected function getAutoIncrement($driver, $table): int
10
    {
11
        $method = "get{$driver}AutoIncrement";
12
13
        return $this->{$method}($table);
14
    }
15
16
    protected function getMysqlAutoIncrement($table): int
17
    {
18
        return data_get(DB::select("SHOW TABLE STATUS WHERE NAME = '{$table}'"), '0.Auto_increment', 0);
19
    }
20
21
    protected function getSqliteAutoIncrement($table): int
22
    {
23
        return data_get(DB::select("SELECT * FROM SQLITE_SEQUENCE WHERE NAME = '{$table}'"), '0.seq', 0);
24
    }
25
}
26