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

TransferTransaction   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 31.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 16
c 1
b 0
f 0
dl 0
loc 57
ccs 5
cts 16
cp 0.3125
rs 10

6 Methods

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