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

ReferenceTransaction   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 53.85%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 13
c 1
b 0
f 0
dl 0
loc 45
ccs 7
cts 13
cp 0.5385
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A canCommit() 0 4 2
A getExtraOptions() 0 3 1
A getId() 0 3 1
A __construct() 0 5 1
A getAmount() 0 3 1
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