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

UniqueId   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A inject() 0 3 1
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