Passed
Push — master ( 8a002b...c640bb )
by Wilmer
05:52 queued 01:51
created

Transaction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

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