MerchantParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 12 3
1
<?php
2
/**
3
 * Merchant parser
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2022 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Payments
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Sisow\XML;
12
13
use Pronamic\WordPress\Pay\Core\XML\Security;
14
use Pronamic\WordPress\Pay\Gateways\Sisow\Merchant;
15
use SimpleXMLElement;
16
17
/**
18
 * Merchant parser
19
 * Description:
20
 * Copyright: 2005-2022 Pronamic
21
 * Company: Pronamic
22
 *
23
 * @author  Reüel van der Steege
24
 * @version 2.0.2
25
 * @since   2.0.2
26
 */
27
class MerchantParser implements Parser {
28
	/**
29
	 * Parse XML element.
30
	 *
31
	 * @param SimpleXMLElement $xml XML element to parse.
32
	 *
33
	 * @return Merchant
34
	 */
35
	public static function parse( SimpleXMLElement $xml ) {
36
		$merchant = new Merchant();
37
38
		if ( isset( $xml->merchantid ) ) {
39
			$merchant->merchant_id = Security::filter( $xml->merchantid );
40
		}
41
42
		if ( isset( $xml->payments->payment ) ) {
43
			$merchant->payments = (array) $xml->payments->payment;
44
		}
45
46
		return $merchant;
47
	}
48
}
49