Passed
Branch reduce-soap-envelope-builder-c... (f028c1)
by Rait
07:42
created

StrAsClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 31
ccs 13
cts 13
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A inject() 0 3 1
1
<?php
2
3
namespace Raigu\XRoad\SoapEnvelope;
4
5
use DOMDocument;
6
use Raigu\XRoad\SoapEnvelope\Element\FragmentInjection;
7
use Raigu\XRoad\SoapEnvelope\Element\XmlInjectable;
8
9
/**
10
 * I create a service element of X-Road SOAP envelope
11
 * which can inject itself into proper place in DOMDocument
12
 */
13
final class StrAsClient implements XmlInjectable
14
{
15
    /**
16
     * @var FragmentInjection
17
     */
18
    private $injection;
19
20 1
    public function inject(DOMDocument $dom): void
21
    {
22 1
        $this->injection->inject($dom);
23 1
    }
24
25 1
    public function __construct(string $reference)
26
    {
27 1
        $client = new StrAsClientReference($reference);
28
29
        $fragment = <<<EOD
30 1
<xrd:client id:objectType="SUBSYSTEM" 
31
    xmlns:xrd="http://x-road.eu/xsd/xroad.xsd"
32
    xmlns:id="http://x-road.eu/xsd/identifiers">
33 1
            <id:xRoadInstance>{$client->xRoadInstance()}</id:xRoadInstance>
34 1
            <id:memberClass>{$client->memberClass()}</id:memberClass>
35 1
            <id:memberCode>{$client->memberCode()}</id:memberCode>
36 1
            <id:subsystemCode>{$client->subSystemCode()}</id:subsystemCode>
37
</xrd:client>
38
EOD;
39
40 1
        $this->injection = new FragmentInjection(
41 1
            'http://schemas.xmlsoap.org/soap/envelope/',
42 1
            'Header',
43
            $fragment
44
        );
45 1
    }
46
}
47