Completed
Push — master ( 2e5d0e...583994 )
by Bartko
06:02
created

_commitTransaction()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
ccs 0
cts 0
cp 0
nc 1
1
<?php
2
namespace StefanoTree\NestedSet\Adapter;
3
4
abstract class NestedTransactionDbAdapterAbstract
5
    implements AdapterInterface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
6
{
7
    private $outerTransactionWasStarted = false;
8
9
    /**
10
     * Start DB transaction
11
     */
12
    abstract protected function _beginTransaction();
13
14
    /**
15
     * Commit DB transaction
16
     */
17
    abstract protected function _commitTransaction();
18
19
    /**
20
     * Rollback DB transaction
21
     */
22
    abstract protected function _rollbackTransaction();
23
24
    /**
25
     * Check if DB transaction has been started
26
     * @return boolean
27
     */
28
    abstract protected function _isInTransaction();
29
30 15
    public function beginTransaction()
31
    {
32 15
        $this->outerTransactionWasStarted = $this->_isInTransaction();
33
34 15
        if (!$this->outerTransactionWasStarted) {
35 15
            $this->_beginTransaction();
36
        }
37 15
    }
38
39 14
    public function commitTransaction()
40
    {
41 14
        if (!$this->outerTransactionWasStarted) {
42 14
            $this->_commitTransaction();
43
        }
44 14
    }
45
46 1
    public function rollbackTransaction()
47
    {
48 1
        if (!$this->outerTransactionWasStarted) {
49 1
            $this->_rollbackTransaction();
50
        }
51 1
    }
52
}
53