Total Complexity | 4 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class SoapEnvelope |
||
13 | { |
||
14 | /** |
||
15 | * @var XmlInjectable[] |
||
16 | */ |
||
17 | private $elements; |
||
18 | |||
19 | /** |
||
20 | * Return SOAP envelope |
||
21 | * |
||
22 | * @return string |
||
23 | */ |
||
24 | 2 | public function asStr(): string |
|
25 | { |
||
26 | $envelope = <<<EOD |
||
27 | 2 | <?xml version="1.0" encoding="UTF-8"?> |
|
28 | <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" |
||
29 | xmlns:id="http://x-road.eu/xsd/identifiers" |
||
30 | xmlns:xrd="http://x-road.eu/xsd/xroad.xsd"> |
||
31 | <env:Header> |
||
32 | <xrd:protocolVersion>4.0</xrd:protocolVersion> |
||
33 | </env:Header> |
||
34 | <env:Body/> |
||
35 | </env:Envelope> |
||
36 | EOD; |
||
37 | |||
38 | 2 | $dom = new \DOMDocument(); |
|
39 | 2 | $dom->loadXML($envelope); |
|
40 | |||
41 | 2 | foreach ($this->elements as $element) { |
|
42 | 2 | $element->inject($dom); |
|
43 | } |
||
44 | |||
45 | 2 | return $dom->saveXML(); |
|
46 | } |
||
47 | |||
48 | 2 | public static function create(XmlInjectable ...$elements) |
|
51 | } |
||
52 | |||
53 | 2 | private function __construct(XmlInjectable ...$elements) |
|
60 |