Passed
Push — master ( 9b125d...f5b0c0 )
by Alexander
11:25 queued 07:35
created

TransactionPDO   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 36
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createSavepoint() 0 3 1
A releaseSavepoint() 0 2 1
A rollBackSavepoint() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql;
6
7
use Throwable;
8
use Yiisoft\Db\Exception\Exception;
9
use Yiisoft\Db\Exception\InvalidConfigException;
10
use Yiisoft\Db\Exception\NotSupportedException;
11
use Yiisoft\Db\Driver\PDO\TransactionPDO as AbstractTransactionPDO;
12
13
final class TransactionPDO extends AbstractTransactionPDO
14
{
15
    /**
16
     * Creates a new savepoint.
17
     *
18
     * @param string $name the savepoint name.
19
     *
20
     * @throws Exception|InvalidConfigException|Throwable
21
     */
22 4
    public function createSavepoint(string $name): void
23
    {
24 4
        $this->db->createCommand("SAVE TRANSACTION $name")->execute();
25
    }
26
27
    /**
28
     * Releases an existing savepoint.
29
     *
30
     * @param string $name the savepoint name.
31
     *
32
     * @throws NotSupportedException
33
     */
34
    public function releaseSavepoint(string $name): void
35
    {
36
        // does nothing as MSSQL does not support this
37
    }
38
39
    /**
40
     * Rolls back to a previously created savepoint.
41
     *
42
     * @param string $name the savepoint name.
43
     *
44
     * @throws Exception|InvalidConfigException|Throwable
45
     */
46 3
    public function rollBackSavepoint(string $name): void
47
    {
48 3
        $this->db->createCommand("ROLLBACK TRANSACTION $name")->execute();
49
    }
50
}
51