Completed
Pull Request — master (#1)
by Dmitry
11:43 queued 10:09
created

setTransactionReference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 1
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace hiqdev\php\merchant\response;
4
5
use Money\Currency;
6
use Money\Money;
7
8
/**
9
 * Class CompletePurchaseResponse
10
 *
11
 * @author Dmytro Naumenko <[email protected]>
12
 */
13
class CompletePurchaseResponse
14
{
15
    /**
16
     * @var bool
17
     */
18
    protected $isSuccessful;
19
    /**
20
     * @var Currency
21
     */
22
    protected $currency;
23
    /**
24
     * @var Money
25
     */
26
    protected $amount;
27
    /**
28
     * @var Money
29
     */
30
    protected $fee;
31
    /**
32
     * @var \DateTime
33
     */
34
    protected $time;
35
    /**
36
     * @var string
37
     */
38
    protected $transactionReference;
39
    /**
40
     * @var string
41
     */
42
    protected $transactionId;
43
    /**
44
     * @var string
45
     */
46
    protected $payer;
47
48
    /**
49
     * @return string
50
     */
51
    public function getTransactionId()
52
    {
53
        return $this->transactionId;
54
    }
55
56
    /**
57
     * @param string $transactionId
58
     * @return CompletePurchaseResponse
59
     */
60
    public function setTransactionId($transactionId)
61
    {
62
        $this->transactionId = $transactionId;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return Currency
69
     */
70
    public function getCurrency()
71
    {
72
        return $this->currency;
73
    }
74
75
    /**
76
     * @return Money
77
     */
78
    public function getAmount(): Money
79
    {
80
        return $this->amount;
81
    }
82
83
    /**
84
     * @param Money $amount
85
     * @return CompletePurchaseResponse
86
     */
87
    public function setAmount(Money $amount)
88
    {
89
        $this->amount = $amount;
90
        $this->currency = $amount->getCurrency();
91
92
        return $this;
93
    }
94
95
    /**
96
     * @return Money
97
     */
98
    public function getFee()
99
    {
100
        if ($this->fee !== null) {
101
            return $this->fee;
102
        }
103
104
        return new Money(0, $this->getCurrency());
105
    }
106
107
    /**
108
     * @param Money $fee
109
     * @return CompletePurchaseResponse
110
     */
111
    public function setFee($fee)
112
    {
113
        $this->fee = $fee;
114
115
        return $this;
116
    }
117
118
    /**
119
     * @return \DateTime of purchase in UTC
120
     */
121
    public function getTime()
122
    {
123
        return $this->time;
124
    }
125
126
    /**
127
     * @param \DateTime $time In UTC
128
     * @return CompletePurchaseResponse
129
     */
130
    public function setTime(\DateTime $time)
131
    {
132
        $this->time = $time;
133
134
        return $this;
135
    }
136
137
    /**
138
     * @return string
139
     */
140
    public function getTransactionReference()
141
    {
142
        return $this->transactionReference;
143
    }
144
145
    /**
146
     * @param string $transactionReference
147
     * @return CompletePurchaseResponse
148
     */
149
    public function setTransactionReference($transactionReference)
150
    {
151
        $this->transactionReference = $transactionReference;
152
153
        return $this;
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function getPayer()
160
    {
161
        return $this->payer;
162
    }
163
164
    /**
165
     * @param string $payer
166
     * @return CompletePurchaseResponse
167
     */
168
    public function setPayer($payer)
169
    {
170
        $this->payer = $payer;
171
172
        return $this;
173
    }
174
175
    /**
176
     * @param string $isSuccessful
177
     * @return CompletePurchaseResponse
178
     */
179
    public function setIsSuccessful($isSuccessful)
180
    {
181
        $this->isSuccessful = $isSuccessful;
0 ignored issues
show
Documentation Bug introduced by
The property $isSuccessful was declared of type boolean, but $isSuccessful is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
182
183
        return $this;
184
    }
185
186
    /**
187
     * @return string
188
     */
189
    public function getIsSuccessful()
190
    {
191
        return $this->isSuccessful;
192
    }
193
}
194