Completed
Push — master ( 52a6e0...c01d36 )
by Dmitriy
51s queued 49s
created

TransactionInterfaceDecorator::commit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Debug;
6
7
use Yiisoft\Db\Transaction\TransactionInterface;
8
9
final class TransactionInterfaceDecorator implements TransactionInterface
10
{
11
    public function __construct(
12
        private TransactionInterface $decorated,
13
        private DatabaseCollector $collector
14
    ) {
15
    }
16
17
    /**
18
     * @psalm-suppress PossiblyUndefinedArrayOffset
19
     */
20
    public function begin(string $isolationLevel = null): void
21
    {
22
        [$callStack] = debug_backtrace();
23
24
        $this->collector->collectTransactionStart($isolationLevel, $callStack['file'] . ':' . $callStack['line']);
25
26
        $this->decorated->begin($isolationLevel);
27
    }
28
29
    /**
30
     * @psalm-suppress PossiblyUndefinedArrayOffset
31
     */
32
    public function commit(): void
33
    {
34
        [$callStack] = debug_backtrace();
35
36
        $this->decorated->commit();
37
38
        $this->collector->collectTransactionCommit($callStack['file'] . ':' . $callStack['line']);
39
    }
40
41
    public function getLevel(): int
42
    {
43
        return $this->decorated->getLevel();
44
    }
45
46
    public function isActive(): bool
47
    {
48
        return $this->decorated->isActive();
49
    }
50
51
    /**
52
     * @psalm-suppress PossiblyUndefinedArrayOffset
53
     */
54
    public function rollBack(): void
55
    {
56
        [$callStack] = debug_backtrace();
57
58
        $this->decorated->rollBack();
59
60
        $this->collector->collectTransactionRollback($callStack['file'] . ':' . $callStack['line']);
61
    }
62
63
    public function setIsolationLevel(string $level): void
64
    {
65
        $this->decorated->{__FUNCTION__}(...func_get_args());
66
    }
67
68
    public function createSavepoint(string $name): void
69
    {
70
        $this->decorated->{__FUNCTION__}(...func_get_args());
71
    }
72
73
    public function rollBackSavepoint(string $name): void
74
    {
75
        $this->decorated->{__FUNCTION__}(...func_get_args());
76
    }
77
78
    public function releaseSavepoint(string $name): void
79
    {
80
        $this->decorated->{__FUNCTION__}(...func_get_args());
81
    }
82
}
83