Passed
Pull Request — master (#57)
by
unknown
01:16
created

Transaction::setVirtualAccount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Kingsquare\Banking;
4
5
/**
6
 * @property string rawData A container after parsing a statement containing 'rawdata' if debug was true on the engine
7
 *
8
 * @author Kingsquare ([email protected])
9
 * @license http://opensource.org/licenses/MIT MIT
10
 */
11
class Transaction implements \JsonSerializable
12
{
13
    const DEBIT = 'D';
14
    const CREDIT = 'C';
15
16
    private $account = '';
17
    private $accountName = '';
18
    private $price = 0.0;
19
    private $debitcredit = '';
20
    private $cancellation = false;
21
    private $description = '';
22
    private $valueTimestamp = 0;
23
    private $entryTimestamp = 0;
24
    private $transactionCode = '';
25
    private $virtualAccount = '';
26
27
    /**
28
     * @return array
29
     */
30
    public function jsonSerialize()
31
    {
32
        return get_object_vars($this);
33
    }
34
35
    /**
36
     * @param string $var
37
     */
38
    public function setAccount($var)
39
    {
40
        $this->account = (string)$var;
41
    }
42
43
    /**
44
     * @param string $var
45
     */
46
    public function setAccountName($var)
47
    {
48
        $this->accountName = (string)$var;
49
    }
50
51
    /**
52
     * @param float $var
53
     */
54
    public function setPrice($var)
55
    {
56
        $this->price = (float)$var;
57
    }
58
59
    /**
60
     * @param string $var
61
     */
62
    public function setDebitCredit($var)
63
    {
64
        $this->debitcredit = (string)$var;
65
    }
66
67
    /**
68
     * @param bool $var
69
     */
70
    public function setCancellation($var)
71
    {
72
        $this->cancellation = (bool)$var;
73
    }
74
75
    /**
76
     * @param string $var
77
     */
78
    public function setDescription($var)
79
    {
80
        $this->description = (string)$var;
81
    }
82
83
    /**
84
     * @param int $var
85
     */
86
    public function setValueTimestamp($var)
87
    {
88
        $this->valueTimestamp = (int)$var;
89
    }
90
91
    /**
92
     * @param int $var
93
     */
94
    public function setEntryTimestamp($var)
95
    {
96
        $this->entryTimestamp = (int)$var;
97
    }
98
99
    /**
100
     * @param string $var
101
     */
102
    public function setTransactionCode($var)
103
    {
104
        $this->transactionCode = (string)$var;
105
    }
106
107
    /**
108
     * @param string $var
109
     */
110
    public function setVirtualAccount($var)
111
    {
112
        $this->virtualAccount = (string)$var;
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    public function getAccount()
119
    {
120
        return $this->account;
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function getAccountName()
127
    {
128
        return $this->accountName;
129
    }
130
131
    /**
132
     * @return float
133
     */
134
    public function getPrice()
135
    {
136
        return $this->price;
137
    }
138
139
    /**
140
     * @return float
141
     */
142
    public function getRelativePrice()
143
    {
144
        $price = $this->getPrice();
145
        return $this->isDebit() ? -$price : $price;
146
    }
147
148
    /**
149
     * @return string
150
     */
151
    public function getDebitCredit()
152
    {
153
        return $this->debitcredit;
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function getDescription()
160
    {
161
        return $this->description;
162
    }
163
164
    /**
165
     * @param string $format
166
     *
167
     * @return string
168
     */
169
    public function getValueTimestamp($format = 'U')
170
    {
171
        return date($format, $this->valueTimestamp);
172
    }
173
174
    /**
175
     * @param string $format
176
     *
177
     * @return string
178
     */
179
    public function getEntryTimestamp($format = 'U')
180
    {
181
        return date($format, $this->entryTimestamp);
182
    }
183
184
    /**
185
     * @return string
186
     */
187
    public function getTransactionCode()
188
    {
189
        return $this->transactionCode;
190
    }
191
192
    /**
193
     * @return string
194
     */
195
    public function getVirtualAccount()
196
    {
197
        return $this->virtualAccount;
198
    }
199
200
    /**
201
     * @return bool
202
     */
203
    public function isDebit()
204
    {
205
        return $this->getDebitCredit() === self::DEBIT;
206
    }
207
208
    /**
209
     * @return bool
210
     */
211
    public function isCredit()
212
    {
213
        return $this->getDebitCredit() === self::CREDIT;
214
    }
215
216
    /**
217
     * @return bool
218
     */
219
    public function isCancellation()
220
    {
221
        return $this->cancellation;
222
    }
223
}
224