NotificationParser   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 22 6
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\IDealBasic\XML;
4
5
use DateTime;
6
use Pronamic\WordPress\Pay\Core\XML\Security;
7
use Pronamic\WordPress\Pay\Gateways\IDealBasic\Notification;
8
use SimpleXMLElement;
9
10
/**
11
 * Title: Issuer XML parser
12
 * Description:
13
 * Copyright: 2005-2021 Pronamic
14
 * Company: Pronamic
15
 *
16
 * @author  Remco Tolsma
17
 * @version 2.0.0
18
 * @since   1.0.0
19
 */
20
class NotificationParser {
21
	/**
22
	 * Parse
23
	 *
24
	 * @param SimpleXMLElement $xml
25
	 * @param Notification $notification
26
	 *
27
	 * @return Notification
28
	 */
29 1
	public static function parse( SimpleXMLElement $xml, $notification = null ) {
30 1
		if ( null === $notification ) {
31 1
			$notification = new Notification();
32
		}
33
34 1
		if ( $xml->createDateTimeStamp ) {
35 1
			$notification->set_date( new DateTime( Security::filter( $xml->createDateTimeStamp ) ) );
36
		}
37
38 1
		if ( $xml->transactionID ) {
39 1
			$notification->set_transaction_id( Security::filter( $xml->transactionID ) );
40
		}
41
42 1
		if ( $xml->purchaseID ) {
43 1
			$notification->set_purchase_id( Security::filter( $xml->purchaseID ) );
44
		}
45
46 1
		if ( $xml->status ) {
47 1
			$notification->set_status( Security::filter( $xml->status ) );
48
		}
49
50 1
		return $notification;
51
	}
52
}
53