Failed Conditions
Pull Request — master (#23)
by Adrien
03:02
created

Connection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 14
c 1
b 0
f 0
dl 0
loc 50
rs 10
ccs 0
cts 21
cp 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A commit() 0 5 1
A beginTransaction() 0 5 1
A prepare() 0 3 1
A __destruct() 0 3 1
A query() 0 5 1
A rollBack() 0 5 1
A exec() 0 5 1
A __construct() 0 3 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 __destruct()
20
    {
21
        _log()->info('Disconnecting');
22
    }
23
24
    public function prepare(string $sql): DriverStatement
25
    {
26
        return new Statement(parent::prepare($sql), $sql);
27
    }
28
29
    public function query(string $sql): Result
30
    {
31
        _log()->debug('Executing query: {sql}', ['sql' => $sql]);
32
33
        return parent::query($sql);
34
    }
35
36
    public function exec(string $sql): int|string
37
    {
38
        _log()->debug('Executing statement: {sql}', ['sql' => $sql]);
39
40
        return parent::exec($sql);
41
    }
42
43
    public function beginTransaction(): void
44
    {
45
        _log()->debug('Beginning transaction');
46
47
        parent::beginTransaction();
48
    }
49
50
    public function commit(): void
51
    {
52
        _log()->debug('Committing transaction');
53
54
        parent::commit();
55
    }
56
57
    public function rollBack(): void
58
    {
59
        _log()->debug('Rolling back transaction');
60
61
        parent::rollBack();
62
    }
63
}
64