1 | <?php |
||
2 | /** |
||
3 | * Directory 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\DateTime\DateTime; |
||
14 | use Pronamic\WordPress\Pay\Core\XML\Security; |
||
15 | use Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Directory; |
||
16 | use SimpleXMLElement; |
||
17 | |||
18 | /** |
||
19 | * Title: Issuer XML parser |
||
20 | * Description: |
||
21 | * Copyright: 2005-2021 Pronamic |
||
22 | * Company: Pronamic |
||
23 | * |
||
24 | * @author Remco Tolsma |
||
25 | * @version 2.0.0 |
||
26 | */ |
||
27 | class DirectoryParser implements Parser { |
||
28 | /** |
||
29 | * Parse |
||
30 | * |
||
31 | * @param SimpleXMLElement $xml XML. |
||
32 | * @return Directory |
||
33 | * @throws \Exception Throws exception on date error. |
||
34 | */ |
||
35 | public static function parse( SimpleXMLElement $xml ) { |
||
36 | $directory = new Directory(); |
||
37 | |||
38 | // Date. |
||
39 | $timestamp = Security::filter( $xml->directoryDateTimestamp ); |
||
40 | |||
41 | if ( null !== $timestamp ) { |
||
42 | $directory->set_date( new DateTime( $timestamp ) ); |
||
43 | } |
||
44 | |||
45 | // Country. |
||
46 | foreach ( $xml->Country as $element ) { |
||
47 | $country = CountryParser::parse( $element ); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
48 | |||
49 | $directory->add_country( $country ); |
||
50 | } |
||
51 | |||
52 | return $directory; |
||
53 | } |
||
54 | } |
||
55 |