Transaction::persist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Isolate\Framework\PersistenceContext;
4
5
use Isolate\PersistenceContext\Transaction as BaseTransaction;
6
use Isolate\UnitOfWork\UnitOfWork;
7
8
/**
9
 * @api
10
 */
11
class Transaction implements BaseTransaction
12
{
13
    /**
14
     * @var UnitOfWork
15
     */
16
    private $unitOfWork;
17
18
    /**
19
     * @param UnitOfWork $unitOfWork
20
     */
21
    public function __construct(UnitOfWork $unitOfWork)
22
    {
23
        $this->unitOfWork = $unitOfWork;
24
    }
25
26
    /**
27
     * @return void
28
     * 
29
     * @api
30
     */
31
    public function commit()
32
    {
33
        $this->unitOfWork->commit();
34
    }
35
36
    /**
37
     * @return void
38
     * 
39
     * @api
40
     */
41
    public function rollback()
42
    {
43
        $this->unitOfWork->rollback();
44
    }
45
46
    /**
47
     * @param mixed $entity
48
     * @return boolean
49
     * 
50
     * @api
51
     */
52
    public function contains($entity)
53
    {
54
        return $this->unitOfWork->isRegistered($entity);
55
    }
56
57
    /**
58
     * @param mixed $entity
59
     * 
60
     * @api
61
     */
62
    public function persist($entity)
63
    {
64
        $this->unitOfWork->register($entity);
65
    }
66
67
    /**
68
     * @param mixed $entity
69
     * 
70
     * @api
71
     */
72
    public function delete($entity)
73
    {
74
        $this->unitOfWork->remove($entity);
75
    }
76
}
77