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

StrAsUserId::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 9
ccs 8
cts 8
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Raigu\XRoad\SoapEnvelope;
4
5
use DOMDocument;
6
use Raigu\XRoad\SoapEnvelope\Element\DOMElementInjection;
7
use Raigu\XRoad\SoapEnvelope\Element\XmlInjectable;
8
9
final class StrAsUserId implements XmlInjectable
10
{
11
    /**
12
     * @var XmlInjectable
13
     */
14
    private $injection;
15
16 1
    public function inject(DOMDocument $dom): void
17
    {
18 1
        $this->injection->inject($dom);
19 1
    }
20
21 1
    public function __construct(string $userId)
22
    {
23 1
        $this->injection = new DOMElementInjection(
24 1
            'http://schemas.xmlsoap.org/soap/envelope/',
25 1
            'Header',
26 1
            new \DOMElement(
27 1
                'userId',
28 1
                (new ValidatedUserId($userId))->asStr(),
29 1
                'http://x-road.eu/xsd/xroad.xsd'
30
            )
31
        );
32 1
    }
33
}
34