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

TransferTransaction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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