Completed
Push — master ( ad55a4...c98fe8 )
by Joachim
01:57
created

CaptureReservation::getTransactionId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Loevgaard\AltaPay\Payload;
3
4
use Assert\Assert;
5
6
class CaptureReservation extends Payload implements CaptureReservationInterface
7
{
8
    use OrderLineArrayTrait;
9
10
    /**
11
     * @var string
12
     */
13
    private $transactionId;
14
15
    /**
16
     * @var float
17
     */
18
    private $amount;
19
20
    /**
21
     * @var string
22
     */
23
    private $reconciliationIdentifier;
24
25
    /**
26
     * @var string
27
     */
28
    private $invoiceNumber;
29
30
    /**
31
     * @var float
32
     */
33
    private $salesTax;
34
35 6
    public function __construct(string $transactionId)
36
    {
37 6
        $this->transactionId = $transactionId;
38 6
        $this->orderLines = [];
39 6
    }
40
41
    /**
42
     * @return array
43
     */
44 3
    public function getPayload() : array
45
    {
46
        $payload = [
47 3
            'transaction_id' => $this->transactionId,
48 3
            'amount' => $this->amount,
49 3
            'reconciliation_identifier' => $this->reconciliationIdentifier,
50 3
            'invoice_number' => $this->invoiceNumber,
51 3
            'sales_tax' => $this->salesTax,
52 3
            'orderLines' => $this->orderLines
53
        ];
54
55 3
        $this->validate();
56
57 3
        return static::simplePayload($payload);
58
    }
59
60 3
    public function validate()
61
    {
62 3
        Assert::that($this->transactionId)->string();
63 3
        Assert::thatNullOr($this->amount)->float();
64 3
        Assert::thatNullOr($this->reconciliationIdentifier)->string();
65 3
        Assert::thatNullOr($this->invoiceNumber)->string();
66 3
        Assert::thatNullOr($this->salesTax)->float();
67 3
        Assert::that($this->orderLines)->isArray();
68 3
    }
69
70
    /**
71
     * @return string
72
     */
73 3
    public function getTransactionId() : string
74
    {
75 3
        return $this->transactionId;
76
    }
77
78
    /**
79
     * @param string $transactionId
80
     * @return CaptureReservation
81
     */
82 3
    public function setTransactionId(string $transactionId) : self
83
    {
84 3
        $this->transactionId = $transactionId;
85 3
        return $this;
86
    }
87
88
    /**
89
     * @return float
90
     */
91 3
    public function getAmount() : ?float
92
    {
93 3
        return $this->amount;
94
    }
95
96
    /**
97
     * @param float $amount
98
     * @return CaptureReservation
99
     */
100 3
    public function setAmount(float $amount) : self
101
    {
102 3
        $this->amount = $amount;
103 3
        return $this;
104
    }
105
106
    /**
107
     * @return string
108
     */
109 3
    public function getReconciliationIdentifier() : ?string
110
    {
111 3
        return $this->reconciliationIdentifier;
112
    }
113
114
    /**
115
     * @param string $reconciliationIdentifier
116
     * @return CaptureReservation
117
     */
118 3
    public function setReconciliationIdentifier(string $reconciliationIdentifier) : self
119
    {
120 3
        $this->reconciliationIdentifier = $reconciliationIdentifier;
121 3
        return $this;
122
    }
123
124
    /**
125
     * @return string
126
     */
127 3
    public function getInvoiceNumber() : ?string
128
    {
129 3
        return $this->invoiceNumber;
130
    }
131
132
    /**
133
     * @param string $invoiceNumber
134
     * @return CaptureReservation
135
     */
136 3
    public function setInvoiceNumber(string $invoiceNumber) : self
137
    {
138 3
        $this->invoiceNumber = $invoiceNumber;
139 3
        return $this;
140
    }
141
142
    /**
143
     * @return float
144
     */
145 3
    public function getSalesTax() : ?float
146
    {
147 3
        return $this->salesTax;
148
    }
149
150
    /**
151
     * @param float $salesTax
152
     * @return CaptureReservation
153
     */
154 3
    public function setSalesTax(float $salesTax) : self
155
    {
156 3
        $this->salesTax = $salesTax;
157 3
        return $this;
158
    }
159
}
160