1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fhp\Model\StatementOfAccount; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Statement |
7
|
|
|
* @package Fhp\Model\StatementOfAccount |
8
|
|
|
*/ |
9
|
|
|
class Statement |
10
|
|
|
{ |
11
|
|
|
const CD_CREDIT = 'credit'; |
12
|
|
|
const CD_DEBIT = 'debit'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var array of Transaction |
16
|
|
|
*/ |
17
|
|
|
protected $transactions = array(); |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var float |
21
|
|
|
*/ |
22
|
|
|
protected $startBalance = 0.0; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $creditDebit; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var \DateTime|null |
31
|
|
|
*/ |
32
|
|
|
protected $date; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get transactions |
36
|
|
|
* |
37
|
|
|
* @return Transaction[] |
38
|
|
|
*/ |
39
|
1 |
|
public function getTransactions() |
40
|
|
|
{ |
41
|
1 |
|
return $this->transactions; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Set transactions |
46
|
|
|
* |
47
|
|
|
* @param array $transactions |
48
|
|
|
* |
49
|
|
|
* @return $this |
50
|
|
|
*/ |
51
|
1 |
|
public function setTransactions(array $transactions = null) |
52
|
|
|
{ |
53
|
1 |
|
$this->transactions = $transactions; |
|
|
|
|
54
|
|
|
|
55
|
1 |
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
1 |
|
public function addTransaction(Transaction $transaction) |
59
|
|
|
{ |
60
|
1 |
|
$this->transactions[] = $transaction; |
61
|
1 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get startBalance |
65
|
|
|
* |
66
|
|
|
* @return float |
67
|
|
|
*/ |
68
|
1 |
|
public function getStartBalance() |
69
|
|
|
{ |
70
|
1 |
|
return $this->startBalance; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getSignedStartBalance() |
74
|
|
|
{ |
75
|
|
|
$s = 1; |
76
|
|
|
if ($this->getCreditDebit() == self::CD_DEBIT) { |
77
|
|
|
$s = -1; |
78
|
|
|
} |
79
|
|
|
return $s * $this->getStartBalance(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set startBalance |
84
|
|
|
* |
85
|
|
|
* @param float $startBalance |
86
|
|
|
* |
87
|
|
|
* @return $this |
88
|
|
|
*/ |
89
|
1 |
|
public function setStartBalance($startBalance) |
90
|
|
|
{ |
91
|
1 |
|
$this->startBalance = (float) $startBalance; |
92
|
|
|
|
93
|
1 |
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Get creditDebit |
98
|
|
|
* |
99
|
|
|
* @return string |
100
|
|
|
*/ |
101
|
1 |
|
public function getCreditDebit() |
102
|
|
|
{ |
103
|
1 |
|
return $this->creditDebit; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Set creditDebit |
108
|
|
|
* |
109
|
|
|
* @param string|null $creditDebit |
110
|
|
|
* |
111
|
|
|
* @return $this |
112
|
|
|
*/ |
113
|
1 |
|
public function setCreditDebit($creditDebit) |
114
|
|
|
{ |
115
|
1 |
|
$this->creditDebit = $creditDebit; |
116
|
|
|
|
117
|
1 |
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get date |
122
|
|
|
* |
123
|
|
|
* @return \DateTime |
124
|
|
|
*/ |
125
|
1 |
|
public function getDate() |
126
|
|
|
{ |
127
|
1 |
|
return $this->date; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Set date |
132
|
|
|
* |
133
|
|
|
* @param \DateTime $date |
134
|
|
|
* |
135
|
|
|
* @return $this |
136
|
|
|
*/ |
137
|
1 |
|
public function setDate(\DateTime $date) |
138
|
|
|
{ |
139
|
1 |
|
$this->date = $date; |
140
|
|
|
|
141
|
1 |
|
return $this; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.
To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.
The function can be called with either null or an array for the parameter
$needle
but will only accept an array as$haystack
.