Completed
Push — master ( 2f7083...d63bf6 )
by Kamil
02:31
created

TransactionBox   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 44
ccs 0
cts 18
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isEmpty() 0 4 1
A add() 0 5 1
A remove() 0 5 1
1
<?php
2
3
namespace Dazzle\MySQL\Support\Transaction;
4
5
use Dazzle\MySQL\TransactionInterface;
6
use SplObjectStorage;
7
8
class TransactionBox implements TransactionBoxInterface
9
{
10
    /**
11
     * @var SplObjectStorage
12
     */
13
    protected $collection;
14
15
    /**
16
     *
17
     */
18
    public function __construct()
19
    {
20
        $this->collection = new SplObjectStorage();
21
    }
22
23
    /**
24
     * @override
25
     * @inheritDoc
26
     */
27
    public function isEmpty()
28
    {
29
        return $this->collection->count() <= 0;
30
    }
31
32
    /**
33
     * @override
34
     * @inheritDoc
35
     */
36
    public function add(TransactionInterface $trans)
37
    {
38
        $this->collection->attach($trans);
39
        return $trans;
40
    }
41
42
    /**
43
     * @override
44
     * @inheritDoc
45
     */
46
    public function remove(TransactionInterface $trans)
47
    {
48
        $this->collection->detach($trans);
49
        return $trans;
50
    }
51
}
52