Passed
Branch reduce-soap-envelope-builder-c... (c98539)
by Rait
02:14
created

UniqueId::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Raigu\XRoad\SoapEnvelope;
4
5
use DOMDocument;
6
use Raigu\XRoad\SoapEnvelope\Element\XmlInjectable;
7
8
/**
9
 * I am a X-Request id.
10
 *
11
 * I assign a random id to myself upon creation.
12
 * I can inject myself into SOAP envelope header
13
 */
14
final class UniqueId implements XmlInjectable
15
{
16
    /**
17
     * @var XmlInjectable
18
     */
19
    private $element;
20
21 1
    public function inject(DOMDocument $dom): void
22
    {
23 1
        $this->element->inject($dom);
24 1
    }
25
26
27 1
    public function __construct()
28
    {
29 1
        $this->element = new Id(
30 1
            bin2hex(random_bytes(16))
31
        );
32 1
    }
33
}
34