Transaction::getEntryTimestamp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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
    /**
107
     * @return string
108
     */
109
    public function getAccount()
110
    {
111
        return $this->account;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getAccountName()
118
    {
119
        return $this->accountName;
120
    }
121
122
    /**
123
     * @return float
124
     */
125
    public function getPrice()
126
    {
127
        return $this->price;
128
    }
129
130
    /**
131
     * @return float
132
     */
133
    public function getRelativePrice()
134
    {
135
        $price = $this->getPrice();
136
        return $this->isDebit() ? -$price : $price;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    public function getDebitCredit()
143
    {
144
        return $this->debitcredit;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function getDescription()
151
    {
152
        return $this->description;
153
    }
154
155
    /**
156
     * @param string $format
157
     *
158
     * @return string
159
     */
160
    public function getValueTimestamp($format = 'U')
161
    {
162
        return date($format, $this->valueTimestamp);
163
    }
164
165
    /**
166
     * @param string $format
167
     *
168
     * @return string
169
     */
170
    public function getEntryTimestamp($format = 'U')
171
    {
172
        return date($format, $this->entryTimestamp);
173
    }
174
175
    /**
176
     * @return string
177
     */
178
    public function getTransactionCode()
179
    {
180
        return $this->transactionCode;
181
    }
182
183
    /**
184
     * @return bool
185
     */
186
    public function isDebit()
187
    {
188
        return $this->getDebitCredit() === self::DEBIT;
189
    }
190
191
    /**
192
     * @return bool
193
     */
194
    public function isCredit()
195
    {
196
        return $this->getDebitCredit() === self::CREDIT;
197
    }
198
199
    /**
200
     * @return bool
201
     */
202
    public function isCancellation()
203
    {
204
        return $this->cancellation;
205
    }
206
}
207