DistributedTracing::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PascalDeVink\CloudEvents\Extension;
6
7
class DistributedTracing implements Extension
8
{
9
    private string $traceParent;
10
11
    private ?string $traceState;
12
13
    public function __construct(string $traceParent, ?string $traceState = null)
14
    {
15
        $this->traceParent = $traceParent;
16
        $this->traceState  = $traceState;
17
    }
18
19
    public function toArray() : array
20
    {
21
        return [
22
            'DistributedTracingExtension' => [
23
                'traceparent' => $this->traceParent,
24
                'tracestate'  => $this->traceState,
25
            ],
26
        ];
27
    }
28
29
    public function getName() : string
30
    {
31
        return 'DistributedTracingExtension';
32
    }
33
34
    public function getTraceParent() : string
35
    {
36
        return $this->traceParent;
37
    }
38
39
    public function getTraceState() : ?string
40
    {
41
        return $this->traceState;
42
    }
43
}
44