Completed
Push — master ( e7c824...3ed60a )
by Anton
10s
created

XML   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 33
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A string() 0 10 2
1
<?php
2
3
namespace {
4
5
	abstract class XML {
6
7
		# Create XML object
8
9
		public static function create(string $data) {
10
11
			$data = ('<?xml version="1.0" encoding="UTF-8" ?>' . $data);
12
13
			return @simplexml_load_string($data);
14
		}
15
16
		# Convert XML object to string
17
18
		public static function string(SimpleXMLElement $xml) {
19
20
			if (false === ($xml = dom_import_simplexml($xml))) return '';
21
22
			$dom = $xml->ownerDocument; $dom->formatOutput = true;
23
24
			# ------------------------
25
26
			return $dom->saveXML();
27
		}
28
29
		# Output XML data
30
31
		public static function output(SimpleXMLElement $xml) {
32
33
			Headers::nocache(); Headers::content(MIME_TYPE_XML);
34
35
			echo self::string($xml);
36
		}
37
	}
38
}
39