Passed
Push — master ( df4ed5...14d15a )
by Remco
21:23 queued 11:46
created

InvoiceParser::parse()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
c 0
b 0
f 0
ccs 0
cts 9
cp 0
rs 10
cc 3
nc 4
nop 1
crap 12
1
<?php
2
/**
3
 * Invoice parser
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 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\Invoice;
15
use SimpleXMLElement;
16
17
/**
18
 * Reservation parser
19
 * Description:
20
 * Copyright: Copyright (c) 2005 - 2018
21
 * Company: Pronamic
22
 *
23
 * @author  Reüel van der Steege
24
 * @version 2.0.1
25
 * @since   2.0.1
26
 */
27
class InvoiceParser implements Parser {
28
	/**
29
	 * Parse XML element.
30
	 *
31
	 * @param SimpleXMLElement $xml XML element to parse.
32
	 *
33
	 * @return Invoice
34
	 */
35
	public static function parse( SimpleXMLElement $xml ) {
36
		$invoice = new Invoice();
37
38
		if ( isset( $xml->invoiceno ) ) {
39
			$invoice->invoiceno = Security::filter( $xml->invoiceno );
40
		}
41
42
		if ( isset( $xml->documentid ) ) {
43
			$invoice->documentid = Security::filter( $xml->documentid );
44
		}
45
46
		return $invoice;
47
	}
48
}
49