Completed
Push — master ( 26e69a...ab0b77 )
by Robin
03:27
created

Transaction::setValueTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
26
    /**
27
     * @return array
28
     */
29
    public function jsonSerialize()
30
    {
31
        return get_object_vars($this);
32
    }
33
34
    /**
35
     * @param string $var
36
     */
37
    public function setAccount($var)
38
    {
39
        $this->account = (string) $var;
40
    }
41
42
    /**
43
     * @param string $var
44
     */
45
    public function setAccountName($var)
46
    {
47
        $this->accountName = (string) $var;
48
    }
49
50
    /**
51
     * @param float $var
52
     */
53
    public function setPrice($var)
54
    {
55
        $this->price = (float) $var;
56
    }
57
58
    /**
59
     * @param string $var
60
     */
61
    public function setDebitCredit($var)
62
    {
63
        $this->debitcredit = (string) $var;
64
    }
65
66
    /**
67
     * @param bool $var
68
     */
69
    public function setCancellation($var)
70
    {
71
        $this->cancellation = (bool) $var;
72
    }
73
74
    /**
75
     * @param string $var
76
     */
77
    public function setDescription($var)
78
    {
79
        $this->description = (string) $var;
80
    }
81
82
    /**
83
     * @param int $var
84
     */
85
    public function setValueTimestamp($var)
86
    {
87
        $this->valueTimestamp = (int) $var;
88
    }
89
90
    /**
91
     * @param int $var
92
     */
93
    public function setEntryTimestamp($var)
94
    {
95
        $this->entryTimestamp = (int) $var;
96
    }
97
98
    /**
99
     * @param string $var
100
     */
101
    public function setTransactionCode($var)
102
    {
103
        $this->transactionCode = (string) $var;
104
    }
105
106
    // getters
107
    /**
108
     * @return string
109
     */
110
    public function getAccount()
111
    {
112
        return $this->account;
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    public function getAccountName()
119
    {
120
        return $this->accountName;
121
    }
122
123
    /**
124
     * @return float
125
     */
126
    public function getPrice()
127
    {
128
        return $this->price;
129
    }
130
131
    /**
132
     * @return string
133
     */
134
    public function getDebitCredit()
135
    {
136
        return $this->debitcredit;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    public function getDescription()
143
    {
144
        return $this->description;
145
    }
146
147
    /**
148
     * @param string $format
149
     *
150
     * @return string
151
     */
152
    public function getValueTimestamp($format = 'U')
153
    {
154
        return date($format, $this->valueTimestamp);
155
    }
156
157
    /**
158
     * @param string $format
159
     *
160
     * @return string
161
     */
162
    public function getEntryTimestamp($format = 'U')
163
    {
164
        return date($format, $this->entryTimestamp);
165
    }
166
167
    /**
168
     * @return string
169
     */
170
    public function getTransactionCode()
171
    {
172
        return $this->transactionCode;
173
    }
174
175
    /**
176
     * @return bool
177
     */
178
    public function isDebit()
179
    {
180
        return $this->getDebitCredit() == self::DEBIT;
181
    }
182
183
    /**
184
     * @return bool
185
     */
186
    public function isCredit()
187
    {
188
        return $this->getDebitCredit() == self::CREDIT;
189
    }
190
191
    /**
192
     * @return bool
193
     */
194
    public function isCancellation()
195
    {
196
        return $this->cancellation;
197
    }
198
}
199