TraceIdHeaderRetriever   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 0
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A retrieve() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\Jaravel\Services;
6
7
use OpenTelemetry\API\Trace\Propagation\TraceContextPropagator;
8
9
class TraceIdHeaderRetriever
10
{
11
    public function retrieve(array $carrier, $headerName = TraceContextPropagator::TRACEPARENT): ?string
12
    {
13
        if (empty($carrier[$headerName])) {
14
            return null;
15
        }
16
17
        if (is_array($carrier[$headerName])) {
18
            return $carrier[$headerName][0];
19
        }
20
21
        return $carrier[$headerName];
22
    }
23
}
24