Total Complexity | 5 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 90% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait Commit |
||
10 | { |
||
11 | /** |
||
12 | * @var bool |
||
13 | */ |
||
14 | private $committed = false; |
||
15 | |||
16 | abstract public function canCommit(); |
||
17 | |||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | 8 | public function commit() |
|
22 | { |
||
23 | 8 | if (!$this->canCommit()) { |
|
24 | throw TransactionException::unableToCommit(); |
||
25 | } |
||
26 | 8 | $this->committed = true; |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 2 | public function isCommitted() |
|
33 | { |
||
34 | 2 | return $this->committed; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 2 | public function allowChanges() |
|
47 | } |
||
48 | } |
||
49 |