src/Zipkin/Propagation/B3.php
public function getExtractor(Getter $getter): callable
    {
        /**
         * @param mixed $carrier
         * @return TraceContext|SamplingFlags
         */
        return function ($carrier) use ($getter) {
            $isSampledRaw = $getter->get($carrier, self::SAMPLED_NAME);

            $isSampled = SamplingFlags::EMPTY_SAMPLED;
            if ($isSampledRaw !== null) {
                if ($isSampledRaw === '1' || strtolower($isSampledRaw) === 'true') {
                    $isSampled = true;
                } elseif ($isSampledRaw === '0' || strtolower($isSampledRaw) === 'false') {
                    $isSampled = false;
                }
            }

            $isDebugRaw = $getter->get($carrier, self::FLAGS_NAME);
            
            /**
             * @var bool|null
             */
            $isDebug = SamplingFlags::EMPTY_DEBUG;
            if ($isDebugRaw !== null) {
                $isDebug = ($isDebugRaw === '1');
            }

            $traceId = $getter->get($carrier, self::TRACE_ID_NAME);

            if ($isSampled === null && $isDebug === null && $traceId === null) {
                return DefaultSamplingFlags::createAsEmpty();
            }

            $spanId = $getter->get($carrier, self::SPAN_ID_NAME);

            if ($spanId === null) {
                return DefaultSamplingFlags::create($isSampled, $isDebug);
            }

            $parentSpanId = $getter->get($carrier, self::PARENT_SPAN_ID_NAME);

            try {
                return TraceContext::create($traceId, $spanId, $parentSpanId, $isSampled, $isDebug);
            } catch (InvalidTraceContextArgument $e) {
                $this->logger->debug(sprintf(
                    'Failed to extract propagated context: %s',
                    $e->getMessage()
                ));

                return DefaultSamplingFlags::createAsEmpty();
            }
        };
    }
public function getExtractor(Getter $getter): callable
    {
        /**
         * @param mixed $carrier
         * @return TraceContext|SamplingFlags
         */
        return function ($carrier) use ($getter) {
            $isSampledRaw = $getter->get($carrier, self::SAMPLED_NAME);

            $isSampled = SamplingFlags::EMPTY_SAMPLED;
            if ($isSampledRaw !== null) {
                if ($isSampledRaw === '1' || strtolower($isSampledRaw) === 'true') {
                    $isSampled = true;
                } elseif ($isSampledRaw === '0' || strtolower($isSampledRaw) === 'false') {
                    $isSampled = false;
                }
            }

            $isDebugRaw = $getter->get($carrier, self::FLAGS_NAME);
            
            /**
             * @var bool|null
             */
            $isDebug = SamplingFlags::EMPTY_DEBUG;
            if ($isDebugRaw !== null) {
                $isDebug = ($isDebugRaw === '1');
            }

            $traceId = $getter->get($carrier, self::TRACE_ID_NAME);

            if ($isSampled === null && $isDebug === null && $traceId === null) {
                return DefaultSamplingFlags::createAsEmpty();
            }

            $spanId = $getter->get($carrier, self::SPAN_ID_NAME);

            if ($spanId === null) {
                return DefaultSamplingFlags::create($isSampled, $isDebug);
            }

            $parentSpanId = $getter->get($carrier, self::PARENT_SPAN_ID_NAME);

            try {
                return TraceContext::create($traceId, $spanId, $parentSpanId, $isSampled, $isDebug);
            } catch (InvalidTraceContextArgument $e) {
                $this->logger->debug(sprintf(
                    'Failed to extract propagated context: %s',
                    $e->getMessage()
                ));

                return DefaultSamplingFlags::createAsEmpty();
            }
        };
    }
{@inheritdoc}