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

TransactionBox::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
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