1 | <?php |
||
15 | class PaymentInformation |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $id; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $transactions; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | protected $batchBooking; |
||
31 | |||
32 | /** |
||
33 | * @var string|null |
||
34 | */ |
||
35 | protected $serviceLevel; |
||
36 | |||
37 | /** |
||
38 | * @var string|null |
||
39 | */ |
||
40 | protected $localInstrument; |
||
41 | |||
42 | /** |
||
43 | * @var CategoryPurposeCode|null |
||
44 | */ |
||
45 | protected $categoryPurpose; |
||
46 | |||
47 | /** |
||
48 | * @var \DateTime |
||
49 | */ |
||
50 | protected $executionDate; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $debtorName; |
||
56 | |||
57 | /** |
||
58 | * @var FinancialInstitutionInterface |
||
59 | */ |
||
60 | protected $debtorAgent; |
||
61 | |||
62 | /** |
||
63 | * @var IBAN |
||
64 | */ |
||
65 | protected $debtorIBAN; |
||
66 | |||
67 | /** |
||
68 | * Constructor |
||
69 | * |
||
70 | * @param string $id Identifier of this group (should be unique within a message) |
||
71 | * @param string $debtorName Name of the debtor |
||
72 | * @param BIC|IID $debtorAgent BIC or IID of the debtor's financial institution |
||
73 | * @param IBAN $debtorIBAN IBAN of the debtor's account |
||
74 | */ |
||
75 | 3 | public function __construct($id, $debtorName, FinancialInstitutionInterface $debtorAgent, IBAN $debtorIBAN) |
|
89 | |||
90 | /** |
||
91 | * Adds a single transaction to this payment |
||
92 | * |
||
93 | * @param CreditTransfer $transaction The transaction to be added |
||
94 | * |
||
95 | * @return PaymentInformation This payment instruction |
||
96 | */ |
||
97 | 2 | public function addTransaction(CreditTransfer $transaction) |
|
103 | |||
104 | /** |
||
105 | * Gets the number of transactions |
||
106 | * |
||
107 | * @return int Number of transactions |
||
108 | */ |
||
109 | 2 | public function getTransactionCount() |
|
113 | |||
114 | /** |
||
115 | * Gets the sum of transactions |
||
116 | * |
||
117 | * @return Money\Mixed Sum of transactions |
||
118 | */ |
||
119 | 2 | public function getTransactionSum() |
|
129 | |||
130 | /** |
||
131 | * Sets the required execution date. |
||
132 | * Where appropriate, the value data is automatically modified to the next possible banking/Post Office working day. |
||
133 | * |
||
134 | * @param \DateTime $executionDate |
||
135 | * |
||
136 | * @return PaymentInformation This payment instruction |
||
137 | */ |
||
138 | public function setExecutionDate(\DateTime $executionDate) |
||
144 | |||
145 | /** |
||
146 | * Sets the batch booking option. |
||
147 | * It is recommended that one payment instruction is created for each currency transferred. |
||
148 | * |
||
149 | * @param bool $batchBooking |
||
150 | * |
||
151 | * @return PaymentInformation This payment instruction |
||
152 | */ |
||
153 | public function setBatchBooking($batchBooking) |
||
159 | |||
160 | /** |
||
161 | * Checks whether the payment type information is included on B- or C-level |
||
162 | * |
||
163 | * @return bool true if it is included on B-level |
||
164 | */ |
||
165 | 4 | public function hasPaymentTypeInformation() |
|
169 | |||
170 | /** |
||
171 | * Gets the local instrument |
||
172 | * |
||
173 | * @return string|null The local instrument |
||
174 | */ |
||
175 | public function getLocalInstrument() |
||
179 | |||
180 | /** |
||
181 | * Gets the service level |
||
182 | * |
||
183 | * @return string|null The service level |
||
184 | */ |
||
185 | public function getServiceLevel() |
||
189 | |||
190 | /** |
||
191 | * Sets the category purpose |
||
192 | * |
||
193 | * @param CategoryPurposeCode $categoryPurpose The category purpose |
||
194 | * |
||
195 | * @return PaymentInformation This payment instruction |
||
196 | */ |
||
197 | 2 | public function setCategoryPurpose(CategoryPurposeCode $categoryPurpose) |
|
203 | |||
204 | /** |
||
205 | * Builds a DOM tree of this payment instruction |
||
206 | * |
||
207 | * @param \DOMDocument $doc |
||
208 | * |
||
209 | * @return \DOMElement The built DOM tree |
||
210 | */ |
||
211 | 5 | public function asDom(\DOMDocument $doc) |
|
271 | |||
272 | 2 | private function inferServiceLevel() |
|
280 | |||
281 | 2 | private function inferLocalInstrument() |
|
289 | } |
||
290 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: