Completed
Push — master ( 60aec0...f632bc )
by Andreas
12:47 queued 10:41
created

InitialTransaction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.037

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 4
cts 6
cp 0.6667
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 4
crap 1.037
1
<?php
2
3
namespace Larium\Pay\Transaction;
4
5
use Larium\Pay\ParamsBag;
6
7
class InitialTransaction implements Initial
8
{
9
    use Commit;
10
11
    /**
12
     * @var int
13
     */
14
    private $amount = 0;
15
16
    /**
17
     * @var string
18
     */
19
    private $currency = '';
20
21
    /**
22
     * @var string
23
     */
24
    private $successUri;
25
26
    /**
27
     * @var string
28
     */
29
    private $cancelUri;
30
31
    /**
32
     * @var ParamsBag
33
     */
34
    private $extraOptions;
35
36 1
    public function __construct(
37
        $amount,
38
        $successUri,
39
        $cancelUri,
40
        array $extraOptions = []
41
    ) {
42 1
        $this->amount = $amount;
43 1
        $this->cancelUri = $cancelUri;
44 1
        $this->successUri = $successUri;
45
        $this->extraOptions = new ParamsBag($extraOptions);
46
    }
47
48
    public function getAmount()
49
    {
50
        return $this->amount;
51
    }
52
53
    public function getSuccessUri()
54
    {
55
        return $this->successUri;
56
    }
57
58
    public function getCancelUri()
59
    {
60
        return $this->cancelUri;
61
    }
62
63
    public function canCommit()
64
    {
65
        return 4 === count(
66
            array_filter([
67
                $this->amount,
68
                $this->currency,
69
                $this->successUri,
70
                $this->cancelUri,
71
            ], 'strlen')
72
        );
73
    }
74
75
    public function getExtraOptions()
76
    {
77
        return $this->extraOptions;
78
    }
79
80
    public function setCurrency($currency)
81
    {
82
        $this->allowChanges();
83
        $this->currency = $currency;
84
    }
85
86
    public function getCurrency()
87
    {
88
        return $this->currency;
89
    }
90
}
91