Passed
Pull Request — master (#2)
by Andreas
11:41
created

ReferenceTransaction::getAmount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Larium\Pay\Transaction;
6
7
use Larium\Pay\ParamsBag;
8
9
abstract class ReferenceTransaction implements Transaction
10
{
11
    use Commit;
12
13
    /**
14
     * @var string
15
     */
16
    private $id;
17
18
    /**
19
     * @var int
20
     */
21
    private $amount = 0;
22
23
    /**
24
     * @var ParamsBag
25
     */
26
    private $extraOptions;
27
28 5
    public function __construct($amount, $id, array $extraOptions = [])
29
    {
30 5
        $this->id = $id;
31 5
        $this->amount = $amount;
32 5
        $this->extraOptions = new ParamsBag($extraOptions);
33
    }
34
35
    public function getAmount()
36
    {
37
        return $this->amount;
38
    }
39
40
    public function getId()
41
    {
42
        return $this->id;
43
    }
44
45 5
    public function canCommit()
46
    {
47 5
        return $this->amount > 0
48 5
            && $this->id !== null;
49
    }
50
51
    public function getExtraOptions()
52
    {
53
        return $this->extraOptions;
54
    }
55
}
56