TraceIdHeaderRetriever::retrieve()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 11
rs 10
cc 3
nc 3
nop 2
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