CountryParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 25
ccs 0
cts 11
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 18 3
1
<?php
2
/**
3
 * Country parser.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2021 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\XML;
12
13
use Pronamic\WordPress\Pay\Core\XML\Security;
14
use Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Country;
15
use SimpleXMLElement;
16
17
/**
18
 * Title: Issuer XML parser
19
 * Description:
20
 * Copyright: 2005-2021 Pronamic
21
 * Company: Pronamic
22
 *
23
 * @author  Remco Tolsma
24
 * @version 2.0.0
25
 */
26
class CountryParser implements Parser {
27
	/**
28
	 * Parse
29
	 *
30
	 * @param SimpleXMLElement $xml XML.
31
	 * @return Country
32
	 */
33
	public static function parse( SimpleXMLElement $xml ) {
34
		$country = new Country();
35
36
		// Name.
37
		$name = Security::filter( $xml->countryNames );
38
39
		if ( null !== $name ) {
40
			$country->set_name( $name );
41
		}
42
43
		// Issuers.
44
		foreach ( $xml->Issuer as $element ) {
45
			$issuer = IssuerParser::parse( $element );
0 ignored issues
show
Bug introduced by
It seems like $element can also be of type null; however, parameter $xml of Pronamic\WordPress\Pay\G...L\IssuerParser::parse() does only seem to accept SimpleXMLElement, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

45
			$issuer = IssuerParser::parse( /** @scrutinizer ignore-type */ $element );
Loading history...
46
47
			$country->add_issuer( $issuer );
48
		}
49
50
		return $country;
51
	}
52
}
53