@@ -22,43 +22,43 @@ discard block |
||
22 | 22 | |
23 | 23 | class XMLArrayTranslator { |
24 | 24 | |
25 | - public static function translate($content){ |
|
25 | + public static function translate($content) { |
|
26 | 26 | $array = array(); |
27 | 27 | try { |
28 | 28 | $node = simplexml_load_string($content); |
29 | 29 | // fix for hhvm |
30 | - if(!is_a($node, 'SimpleXMLElement')){ |
|
30 | + if (!is_a($node, 'SimpleXMLElement')) { |
|
31 | 31 | throw new Exception('loading XML failed'); |
32 | 32 | } |
33 | 33 | |
34 | 34 | } |
35 | - catch(\Exception $e){ |
|
35 | + catch (\Exception $e) { |
|
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | |
39 | 39 | return self::doTranslate($node); |
40 | 40 | } |
41 | 41 | |
42 | - protected static function doTranslate(\SimpleXMLElement $node){ |
|
42 | + protected static function doTranslate(\SimpleXMLElement $node) { |
|
43 | 43 | |
44 | 44 | $array = array(); |
45 | 45 | $array['type'] = $node['type'] |
46 | 46 | ? (string)$node['type'] |
47 | 47 | : (string)$node->getName(); |
48 | 48 | $value = (string)$node; |
49 | - if($value != ''){ |
|
49 | + if ($value != '') { |
|
50 | 50 | $array['value'] = $value; |
51 | 51 | } |
52 | 52 | |
53 | - foreach($node->attributes() as $name=>$value){ |
|
53 | + foreach ($node->attributes() as $name=>$value) { |
|
54 | 54 | $array[$name] = (string)$value; |
55 | 55 | } |
56 | - foreach($node->children() as $nr=>$child){ |
|
56 | + foreach ($node->children() as $nr=>$child) { |
|
57 | 57 | $name = $child->getName(); |
58 | 58 | $res = self::doTranslate($child); |
59 | 59 | |
60 | - if(isset($array[$name])){ |
|
61 | - if(is_string($array[$name])){ |
|
60 | + if (isset($array[$name])) { |
|
61 | + if (is_string($array[$name])) { |
|
62 | 62 | $array[$name] = array( |
63 | 63 | array( |
64 | 64 | 'type'=>$name, |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ) |
67 | 67 | ); |
68 | 68 | } |
69 | - }else{ |
|
69 | + }else { |
|
70 | 70 | $array[$name] = array(); |
71 | 71 | } |
72 | 72 | $array[$name][] = $res; |