@@ -44,46 +44,39 @@ private function parse($xmlData = ''): void
4444 {
4545 if (!$ this ->isHttpsRequest ()) {
4646 $ this ->exitWithError ('Not HTTPS ' );
47- return ;
4847 }
4948
5049 if ($ _SERVER ['REQUEST_METHOD ' ] !== 'POST ' ) {
5150 $ this ->exitWithError ('Not POST ' );
52- return ;
5351 }
5452
5553 // Check: content type: XML with utf-8 encoding
5654 if ($ _SERVER ["CONTENT_TYPE " ] !== self ::XML_UTF8_CONTENT_TYPE ) {
5755 $ this ->exitWithError ('Wrong Content-Type given: should be XML with UTF-8 encoding ' );
58- return ;
5956 }
6057
6158 // Check: An empty POST to the URL (normal HTTP request) always has to respond with HTTP 200 OK.
6259 $ xmlData = file_get_contents ('php://input ' );
6360
6461 if (empty ($ xmlData )) {
6562 $ this ->exitWithError ('No data body given ' );
66- return ;
6763 }
6864 }
6965
7066 $ xmlObject = $ this ->parseRawXML ($ xmlData );
7167
72- if (! $ xmlObject instanceof \ SimpleXMLElement) {
68+ if (! $ xmlObject instanceof SimpleXMLElement) {
7369 $ this ->exitWithError ('Could not parse XML ' );
74- return ;
7570 }
7671
7772 $ xmlValidation = (new WebhookXmlValidation ($ this ->senderID ))->validate ($ xmlObject );
7873 if (! $ xmlValidation ::$ isValid ) {
7974 $ this ->exitWithError ($ xmlValidation ->errorMessage ());
80- return ;
8175 }
8276
8377 $ signatureValidation = (new WebhookSignatureValidation ($ this ->environment ))->validate ($ xmlData );
8478 if (! $ signatureValidation ::$ isValid ) {
8579 $ this ->exitWithError ($ signatureValidation ->errorMessage ());
86- return ;
8780 }
8881
8982 $ this ->xmlObject = $ xmlObject ;
@@ -98,10 +91,11 @@ private function isHttpsRequest(): bool
9891 || $ _SERVER ['SERVER_PORT ' ] === 443
9992 );
10093 }
101-
102- private function exitWithError (string $ string ): void
94+
95+ private function exitWithError (string $ errorMessage ): void
10396 {
10497 http_response_code (self ::STATUSCODE_BAD_REQUEST );
98+ exit ($ errorMessage );
10599 }
106100
107101 private function parseRawXML ($ postData ): string |SimpleXMLElement
@@ -144,7 +138,7 @@ private function getPayloadValue(string $key): SimpleXMLElement|string|null
144138 if ((is_countable ($ payload ->children ()) ? count ($ payload ->children ()) : 0 ) > 0 ) {
145139 return $ payload ;
146140 }
147- return $ payload ->$ key ?? '' ;
141+ return $ payload ->$ key ? ( $ payload -> $ key . '' ) : '' ;
148142 }
149143
150144 private function getPayload (): SimpleXMLElement
@@ -261,31 +255,31 @@ public function getIDealDetails(): ?SimpleXMLElement
261255 {
262256 $ paymentDetails = $ this ->getPaymentMethodDetails ();
263257
264- if (!$ paymentDetails instanceof \ SimpleXMLElement) {
258+ if (!$ paymentDetails instanceof SimpleXMLElement) {
265259 return null ;
266260 }
267261 return $ paymentDetails ->IDealDetails ;
268262 }
269263 public function getDebtorAccountName (): ?string
270264 {
271265 $ details = $ this ->getIDealDetails ();
272- if (!$ details instanceof \ SimpleXMLElement) {
266+ if (!$ details instanceof SimpleXMLElement) {
273267 return "" ;
274268 }
275269 return $ details ->DebtorAccountName ."" ?? "" ;
276270 }
277271 public function getDebtorIBAN (): ?string
278272 {
279273 $ details = $ this ->getIDealDetails ();
280- if (!$ details instanceof \ SimpleXMLElement) {
274+ if (!$ details instanceof SimpleXMLElement) {
281275 return "" ;
282276 }
283277 return $ details ->DebtorIBAN ."" ?? "" ;
284278 }
285279 public function getDebtorBankID (): ?string
286280 {
287281 $ details = $ this ->getIDealDetails ();
288- if (!$ details instanceof \ SimpleXMLElement) {
282+ if (!$ details instanceof SimpleXMLElement) {
289283 return "" ;
290284 }
291285 return $ details ->DebtorBankID ."" ?? "" ;
@@ -358,7 +352,7 @@ public function getIdentityReportArray(): array
358352 {
359353 $ report = $ this ->getPayload ()->IdentityReport ?? null ;
360354
361- if (!$ report instanceof \ SimpleXMLElement) {
355+ if (!$ report instanceof SimpleXMLElement) {
362356 return [];
363357 }
364358
0 commit comments