GetAttribute::getSqliteAutoIncrement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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