DatabaseInfo::getTableList()   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 0
1
<?php
2
3
namespace Sausin\DBSetAutoIncrement;
4
5
use Illuminate\Support\Facades\DB;
6
7
trait DatabaseInfo
8
{
9
    protected function isDatabaseCompatible(): bool
10
    {
11
        $this->driver = $this->getDatabaseName();
0 ignored issues
show
Bug introduced by
The property driver does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
12
13
        return in_array($this->driver, $this->supportedDrivers);
0 ignored issues
show
Bug introduced by
The property supportedDrivers does not seem to exist. Did you mean driver?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
14
    }
15
16
    protected function getDatabaseName(): string
17
    {
18
        return DB::connection()->getPdo()->getAttribute(\PDO::ATTR_DRIVER_NAME);
19
    }
20
21
    protected function getTableList(): array
22
    {
23
        return DB::connection()->getDoctrineSchemaManager()->listTableNames();
24
    }
25
}
26