1 | <?php |
||
16 | class PaymentInformation |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $id; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $transactions; |
||
27 | |||
28 | /** |
||
29 | * @var bool |
||
30 | */ |
||
31 | protected $batchBooking; |
||
32 | |||
33 | /** |
||
34 | * @var string|null |
||
35 | */ |
||
36 | protected $serviceLevel; |
||
37 | |||
38 | /** |
||
39 | * @var string|null |
||
40 | */ |
||
41 | protected $localInstrument; |
||
42 | |||
43 | /** |
||
44 | * @var CategoryPurposeCode|null |
||
45 | */ |
||
46 | protected $categoryPurpose; |
||
47 | |||
48 | /** |
||
49 | * @var \DateTime |
||
50 | */ |
||
51 | protected $executionDate; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $debtorName; |
||
57 | |||
58 | /** |
||
59 | * @var FinancialInstitutionInterface |
||
60 | */ |
||
61 | protected $debtorAgent; |
||
62 | |||
63 | /** |
||
64 | * @var IBAN |
||
65 | */ |
||
66 | protected $debtorIBAN; |
||
67 | |||
68 | /** |
||
69 | * Constructor |
||
70 | * |
||
71 | * @param string $id Identifier of this group (should be unique within a message) |
||
72 | * @param string $debtorName Name of the debtor |
||
73 | * @param BIC|IID $debtorAgent BIC or IID of the debtor's financial institution |
||
74 | * @param IBAN $debtorIBAN IBAN of the debtor's account |
||
75 | * |
||
76 | * @throws \InvalidArgumentException When any of the inputs contain invalid characters or are too long. |
||
77 | */ |
||
78 | 4 | public function __construct($id, $debtorName, FinancialInstitutionInterface $debtorAgent, IBAN $debtorIBAN) |
|
92 | |||
93 | /** |
||
94 | * Adds a single transaction to this payment |
||
95 | * |
||
96 | * @param CreditTransfer $transaction The transaction to be added |
||
97 | * |
||
98 | * @return PaymentInformation This payment instruction |
||
99 | */ |
||
100 | 3 | public function addTransaction(CreditTransfer $transaction) |
|
106 | |||
107 | /** |
||
108 | * Gets the number of transactions |
||
109 | * |
||
110 | * @return int Number of transactions |
||
111 | */ |
||
112 | 2 | public function getTransactionCount() |
|
116 | |||
117 | /** |
||
118 | * Gets the sum of transactions |
||
119 | * |
||
120 | * @return Money\Mixed Sum of transactions |
||
121 | */ |
||
122 | 2 | public function getTransactionSum() |
|
132 | |||
133 | /** |
||
134 | * Sets the required execution date. |
||
135 | * Where appropriate, the value data is automatically modified to the next possible banking/Post Office working day. |
||
136 | * |
||
137 | * @param \DateTime $executionDate |
||
138 | * |
||
139 | * @return PaymentInformation This payment instruction |
||
140 | */ |
||
141 | public function setExecutionDate(\DateTime $executionDate) |
||
147 | |||
148 | /** |
||
149 | * Sets the batch booking option. |
||
150 | * It is recommended that one payment instruction is created for each currency transferred. |
||
151 | * |
||
152 | * @param bool $batchBooking |
||
153 | * |
||
154 | * @return PaymentInformation This payment instruction |
||
155 | */ |
||
156 | public function setBatchBooking($batchBooking) |
||
162 | |||
163 | /** |
||
164 | * Checks whether the payment type information is included on B- or C-level |
||
165 | * |
||
166 | * @return bool true if it is included on B-level |
||
167 | */ |
||
168 | 4 | public function hasPaymentTypeInformation() |
|
172 | |||
173 | /** |
||
174 | * Gets the local instrument |
||
175 | * |
||
176 | * @return string|null The local instrument |
||
177 | */ |
||
178 | public function getLocalInstrument() |
||
182 | |||
183 | /** |
||
184 | * Gets the service level |
||
185 | * |
||
186 | * @return string|null The service level |
||
187 | */ |
||
188 | public function getServiceLevel() |
||
192 | |||
193 | /** |
||
194 | * Sets the category purpose |
||
195 | * |
||
196 | * @param CategoryPurposeCode $categoryPurpose The category purpose |
||
197 | * |
||
198 | * @return PaymentInformation This payment instruction |
||
199 | */ |
||
200 | 3 | public function setCategoryPurpose(CategoryPurposeCode $categoryPurpose) |
|
206 | |||
207 | /** |
||
208 | * Builds a DOM tree of this payment instruction |
||
209 | * |
||
210 | * @param \DOMDocument $doc |
||
211 | * |
||
212 | * @return \DOMElement The built DOM tree |
||
213 | */ |
||
214 | 5 | public function asDom(\DOMDocument $doc) |
|
279 | |||
280 | 2 | private function inferServiceLevel() |
|
288 | |||
289 | 2 | private function inferLocalInstrument() |
|
297 | } |
||
298 |
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: