Test Failed
Push — master ( 02fa5e...33a8da )
by Mr
01:48
created

ConnectorTrait::getSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Daikon\Dbal\Connector;
4
5
trait ConnectorTrait
6
{
7
    private $settings;
8
9
    private $connection;
10
11
    public function __construct(array $settings)
12
    {
13
        $this->settings = $settings;
14
    }
15
16
    public function __destruct()
17
    {
18
        $this->disconnect();
19
    }
20
21
    public function getConnection()
22
    {
23
        if (!$this->isConnected()) {
24
            $this->connection = $this->connect();
0 ignored issues
show
Bug introduced by
The method connect() does not exist on Daikon\Dbal\Connector\ConnectorTrait. Did you maybe mean getConnection()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
25
        }
26
27
        return $this->connection;
28
    }
29
30
    public function isConnected(): bool
31
    {
32
        return $this->connection !== null;
33
    }
34
35
    public function disconnect(): void
36
    {
37
        if ($this->isConnected()) {
38
            $this->connection = null;
39
        }
40
    }
41
42
    public function getSettings(): array
43
    {
44
        return $this->settings;
45
    }
46
}