Passed
Pull Request — master (#23)
by Adrien
17:46 queued 04:32
created

Connection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\DBAL\Logging;
6
7
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
8
use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware;
9
use Doctrine\DBAL\Driver\Result;
10
use Doctrine\DBAL\Driver\Statement as DriverStatement;
11
12
final class Connection extends AbstractConnectionMiddleware
13
{
14
    public function __construct(ConnectionInterface $connection)
15
    {
16
        parent::__construct($connection);
17
    }
18
19
    public function prepare(string $sql): DriverStatement
20
    {
21
        return new Statement(parent::prepare($sql), $sql);
22
    }
23
24
    public function query(string $sql): Result
25
    {
26
        _log()->debug('Executing query: {sql}', ['sql' => $sql]);
27
28
        return parent::query($sql);
29
    }
30
31
    public function exec(string $sql): int|string
32
    {
33
        _log()->debug('Executing statement: {sql}', ['sql' => $sql]);
34
35
        return parent::exec($sql);
36
    }
37
38
    public function beginTransaction(): void
39
    {
40
        _log()->debug('Beginning transaction');
41
42
        parent::beginTransaction();
43
    }
44
45
    public function commit(): void
46
    {
47
        _log()->debug('Committing transaction');
48
49
        parent::commit();
50
    }
51
52
    public function rollBack(): void
53
    {
54
        _log()->debug('Rolling back transaction');
55
56
        parent::rollBack();
57
    }
58
}
59