Passed
Pull Request — master (#123)
by
unknown
02:01
created

DHConnection   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 19
c 1
b 0
f 0
dl 0
loc 65
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A query() 0 3 1
A beginTransaction() 0 3 1
A __construct() 0 4 1
A prepare() 0 3 1
A commit() 0 9 2
A exec() 0 3 1
A quote() 0 3 1
A getNativeConnection() 0 3 1
A lastInsertId() 0 3 1
A rollBack() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\Auditor\Provider\Doctrine\Auditing\Logger\Middleware;
6
7
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
8
use Doctrine\DBAL\Driver\Result;
9
use Doctrine\DBAL\Driver\Statement;
10
use Doctrine\DBAL\ParameterType;
11
12
/**
13
 * @interal
14
 */
15
final class DHConnection implements ConnectionInterface
16
{
17
    private ConnectionInterface $connection;
18
    private DHDriver $DHDriver;
19
20
    public function __construct(ConnectionInterface $connection, DHDriver $DHDriver)
21
    {
22
        $this->connection = $connection;
23
        $this->DHDriver = $DHDriver;
24
    }
25
26
    public function prepare(string $sql): Statement
27
    {
28
        return $this->connection->prepare($sql);
29
    }
30
31
    public function query(string $sql): Result
32
    {
33
        return $this->connection->query($sql);
34
    }
35
36
    public function quote($value, $type = ParameterType::STRING)
37
    {
38
        return $this->connection->quote($value, $type);
39
    }
40
41
    public function exec(string $sql): int
42
    {
43
        return $this->connection->exec($sql);
44
    }
45
46
    public function lastInsertId($name = null)
47
    {
48
        return $this->connection->lastInsertId($name);
49
    }
50
51
    public function beginTransaction(): bool
52
    {
53
        return $this->connection->beginTransaction();
54
    }
55
56
    public function commit(): bool
57
    {
58
        $flusherList = $this->DHDriver->getFlusherList();
59
        foreach ($flusherList as $flusher) {
60
            ($flusher)();
61
        }
62
        $this->DHDriver->resetDHFlusherList();
63
64
        return $this->connection->commit();
65
    }
66
67
    public function rollBack(): bool
68
    {
69
        $this->DHDriver->resetDHFlusherList();
70
71
        return $this->connection->rollBack();
72
    }
73
74
    /**
75
     * @return object|resource
76
     */
77
    public function getNativeConnection()
78
    {
79
        return $this->connection->getNativeConnection();
0 ignored issues
show
Bug introduced by
The method getNativeConnection() does not exist on Doctrine\DBAL\Driver\Connection. It seems like you code against a sub-type of said class. However, the method does not exist in Doctrine\DBAL\Driver\ServerInfoAwareConnection. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

79
        return $this->connection->/** @scrutinizer ignore-call */ getNativeConnection();
Loading history...
80
    }
81
}
82