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

Connection::commit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
ccs 0
cts 3
cp 0
cc 1
nc 1
nop 0
crap 2
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