Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 5 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | abstract class BaseXmlGenerator implements XmlGeneratorContract |
||
16 | { |
||
17 | protected SimpleXMLElement $xmlElement; |
||
18 | |||
19 | abstract protected function constructBaseElement(): void; |
||
20 | |||
21 | public static function make(): string |
||
22 | { |
||
23 | return (new static)->generate()->getXML(); |
||
24 | } |
||
25 | |||
26 | public function __construct() |
||
27 | { |
||
28 | throw_unless(extension_loaded('simplexml'), |
||
29 | new Exception('The SimpleXML extension is required to generate RSS feeds and sitemaps.') |
||
30 | ); |
||
31 | |||
32 | $this->constructBaseElement(); |
||
33 | } |
||
34 | |||
35 | public function getXml(): string |
||
38 | } |
||
39 | |||
40 | public function getXmlElement(): SimpleXMLElement |
||
43 | } |
||
44 | |||
45 | protected function escape(string $string): string |
||
48 | } |
||
49 | |||
50 | protected function addChild(SimpleXMLElement $element, string $name, string $value): SimpleXMLElement |
||
55 |