1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kingsquare\Banking; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @property array rawData used for debugging purposes |
7
|
|
|
* |
8
|
|
|
* @author Kingsquare ([email protected]) |
9
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
10
|
|
|
*/ |
11
|
|
|
class Statement implements \JsonSerializable |
12
|
|
|
{ |
13
|
|
|
private $bank = ''; |
14
|
|
|
private $account = ''; |
15
|
|
|
private $transactions = []; |
16
|
|
|
private $startPrice = 0.0; |
17
|
|
|
private $endPrice = 0.0; |
18
|
|
|
private $startTimestamp = 0; |
19
|
|
|
private $endTimestamp = 0; |
20
|
|
|
private $number = ''; |
21
|
|
|
private $currency = ''; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
|
|
public function jsonSerialize() |
27
|
|
|
{ |
28
|
|
|
return get_object_vars($this); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param string $var |
33
|
|
|
*/ |
34
|
|
|
public function setBank($var) |
35
|
|
|
{ |
36
|
|
|
$this->bank = (string)$var; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param string $var |
41
|
|
|
*/ |
42
|
|
|
public function setAccount($var) |
43
|
|
|
{ |
44
|
|
|
$this->account = (string)$var; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param Transaction[] $transactions |
49
|
|
|
*/ |
50
|
|
|
public function setTransactions($transactions) |
51
|
|
|
{ |
52
|
|
|
$this->transactions = (array)$transactions; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param float $var |
57
|
|
|
*/ |
58
|
|
|
public function setStartPrice($var) |
59
|
|
|
{ |
60
|
|
|
$this->startPrice = (float)$var; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param float $var |
65
|
|
|
*/ |
66
|
|
|
public function setEndPrice($var) |
67
|
|
|
{ |
68
|
|
|
$this->endPrice = (float)$var; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @deprecated |
73
|
|
|
* |
74
|
|
|
* @param int $var |
75
|
|
|
*/ |
76
|
|
|
public function setTimestamp($var) |
77
|
|
|
{ |
78
|
|
|
trigger_error('Deprecated in favor of splitting the start and end timestamps for a statement. ' . |
79
|
|
|
'Please use setStartTimestamp($format) or setEndTimestamp($format) instead. ' . |
80
|
|
|
'setTimestamp is now setStartTimestamp', E_USER_DEPRECATED); |
81
|
|
|
return $this->setStartTimestamp($var); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param $var |
86
|
|
|
*/ |
87
|
|
|
public function setStartTimestamp($var) |
88
|
|
|
{ |
89
|
|
|
$this->startTimestamp = (int)$var; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param $var |
94
|
|
|
*/ |
95
|
|
|
public function setEndTimestamp($var) |
96
|
|
|
{ |
97
|
|
|
$this->endTimestamp = (int)$var; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param string $var |
102
|
|
|
*/ |
103
|
|
|
public function setNumber($var) |
104
|
|
|
{ |
105
|
|
|
$this->number = (string)$var; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param string $var |
110
|
|
|
*/ |
111
|
|
|
public function setCurrency($var) |
112
|
|
|
{ |
113
|
|
|
$this->currency = (string)$var; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
|
|
public function getBank() |
120
|
|
|
{ |
121
|
|
|
return $this->bank; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return string |
126
|
|
|
*/ |
127
|
|
|
public function getAccount() |
128
|
|
|
{ |
129
|
|
|
return $this->account; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return Transaction[] |
134
|
|
|
*/ |
135
|
|
|
public function getTransactions() |
136
|
|
|
{ |
137
|
|
|
return $this->transactions; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return float |
142
|
|
|
*/ |
143
|
|
|
public function getStartPrice() |
144
|
|
|
{ |
145
|
|
|
return $this->startPrice; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return float |
150
|
|
|
*/ |
151
|
|
|
public function getEndPrice() |
152
|
|
|
{ |
153
|
|
|
return $this->endPrice; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param string $format |
158
|
|
|
* |
159
|
|
|
* @deprecated This method will be removed in favor of getStartTimestamp / getEndTimestamp this is slated for removal in next major |
160
|
|
|
* |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
|
|
public function getTimestamp($format = 'U') |
164
|
|
|
{ |
165
|
|
|
trigger_error('Deprecated in favor of splitting the start and end timestamps for a statement. ' . |
166
|
|
|
'Please use getStartTimestamp($format) or getEndTimestamp($format) instead. ' . |
167
|
|
|
'getTimestamp is now getStartTimestamp', E_USER_DEPRECATED); |
168
|
|
|
|
169
|
|
|
return $this->getStartTimestamp($format); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param string $format |
174
|
|
|
* |
175
|
|
|
* @return bool|string |
176
|
|
|
*/ |
177
|
|
|
public function getStartTimestamp($format = 'U') |
178
|
|
|
{ |
179
|
|
|
return date($format, $this->startTimestamp); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param string $format |
184
|
|
|
* |
185
|
|
|
* @return bool|string |
186
|
|
|
*/ |
187
|
|
|
public function getEndTimestamp($format = 'U') |
188
|
|
|
{ |
189
|
|
|
return date($format, $this->endTimestamp); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @return string |
194
|
|
|
*/ |
195
|
|
|
public function getNumber() |
196
|
|
|
{ |
197
|
|
|
return $this->number; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return string |
202
|
|
|
*/ |
203
|
|
|
public function getCurrency() |
204
|
|
|
{ |
205
|
|
|
return $this->currency; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @param Transaction $transaction |
210
|
|
|
*/ |
211
|
|
|
public function addTransaction(Transaction $transaction) |
212
|
|
|
{ |
213
|
|
|
$this->transactions[] = $transaction; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return float |
218
|
|
|
*/ |
219
|
|
|
public function getDeltaPrice() |
220
|
|
|
{ |
221
|
|
|
return $this->getStartPrice() - $this->getEndPrice(); |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.