InitialTransaction::getCurrency()   A
last analyzed

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
class InitialTransaction implements Initial
10
{
11
    use Commit;
12
13
    /**
14
     * @var int
15
     */
16
    private $amount = 0;
17
18
    /**
19
     * @var string
20
     */
21
    private $currency = '';
22
23
    /**
24
     * @var string
25
     */
26
    private $successUri;
27
28
    /**
29
     * @var string
30
     */
31
    private $cancelUri;
32
33
    /**
34
     * @var ParamsBag
35
     */
36
    private $extraOptions;
37
38 1
    public function __construct(
39
        $amount,
40
        $successUri,
41
        $cancelUri,
42
        array $extraOptions = []
43
    ) {
44 1
        $this->amount = $amount;
45 1
        $this->cancelUri = $cancelUri;
46 1
        $this->successUri = $successUri;
47 1
        $this->extraOptions = new ParamsBag($extraOptions);
48
    }
49
50
    public function getAmount()
51
    {
52
        return $this->amount;
53
    }
54
55
    public function getSuccessUri()
56
    {
57
        return $this->successUri;
58
    }
59
60
    public function getCancelUri()
61
    {
62
        return $this->cancelUri;
63
    }
64
65
    public function canCommit()
66
    {
67
        return 4 === count(
68
            array_filter([
69
                $this->amount,
70
                $this->currency,
71
                $this->successUri,
72
                $this->cancelUri,
73
            ], 'strlen')
74
        );
75
    }
76
77
    public function getExtraOptions()
78
    {
79
        return $this->extraOptions;
80
    }
81
82
    public function setCurrency($currency)
83
    {
84
        $this->allowChanges();
85
        $this->currency = $currency;
86
    }
87
88
    public function getCurrency()
89
    {
90
        return $this->currency;
91
    }
92
}
93