Generate a SpanContext object from the Trace Context header

@param string $header
@return SpanContext
516148
public function deserialize($bin)
    {
        $data = @unpack('Cversion/Cfield0/H32traceId/Cfield1/H16spanId/Cfield2/Coptions', $bin);
        if ($data === false) {
            trigger_error('Invalid binary format for SpanContext', E_USER_WARNING);
            return new SpanContext();
        }
        $enabled = !!($data['options'] & self::OPTION_ENABLED);
        $spanId = $data['spanId'] == "0000000000000000"
            ? null
            : $data['spanId'];
        return new SpanContext($data['traceId'], $spanId, $enabled, true);
    }
1097007
public function connectAsync(ConnectionContext $ctx, string $header = ''): \Generator
    {
        $this->dc = $ctx->getIntDc();
        $stream = yield $ctx->getStream();
        $resource = $stream->getStream()->getResource();

        $this->compressionFactory = new Rfc7692CompressionFactory;

        $handshake = new Handshake(str_replace('tcp://', $ctx->isSecure() ? 'ws://' : 'wss://', $ctx->getStringUri()));

        $key = generateKey();
        yield $stream->write($this->generateRequest($handshake, $key));

        $buffer = '';
        while (($chunk = yield $stream->read()) !== null) {
            $buffer .= $chunk;
            if ($position = \strpos($buffer, "\r\n\r\n")) {
                $headerBuffer = \substr($buffer, 0, $position + 4);
                $buffer = \substr($buffer, $position + 4);
                $headers = $this->handleResponse($headerBuffer, $key);

                $client = new Rfc6455Client(
                    new ClientSocket($resource, $buffer),
                    $handshake->getOptions(),
                    true
                );
                $this->stream = new Rfc6455Connection($client, $headers);
                //$this->stream = new Rfc6455Connection($this->stream, $headers, $buffer);
                break;
            }
        }
        if (!$this->stream) {
            throw new ConnectionException('Failed to read response from server');
        }
        yield $this->write($header);
    }
1271531
public function getHeaderLine(string $header): ?string
    {
        $headers = $this->header->get($header);

        return $headers === [] ? null : \implode(', ', $headers);
    }
478498
public function header($header) {
        foreach($this->_headers as $k => $v) {
            if (!strcasecmp($k, $header)) {
                return $v;
            }
        }
        
        return null;
    }
396464
public function replace($header)
    {
        foreach ($this as $index => $string) {
            $this->dequeue();
        }

        return $this->prepend($header);
    }
293729
public function removeHeader($header)
	{
		if($header instanceof HttpHeaderInterface)
		{
			unset($this->headers[strtolower($header->getFieldName())]);
		}
		else
		{
			unset($this->headers[strtolower($header)]);
		}
		
		return $this;
	}
765756
protected function parseCacheControl($header)
    {
        $cacheControl = [];
        \preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
        foreach ($matches as $match) {
            $cacheControl[\strtolower($match[1])] = $match[3] ?? ($match[2] ?? true);
        }

        return $cacheControl;
    }
91329
function add($header)
    {
        // convert to object form
        if (is_string($header))
            $header = HeaderField::fromString($header);

        $this->_headers[] = $header;
        return $this;
    }
811088
public function addCustomHeader($header)
    {
        self::$headers[self::CUSTOM_HEADERS][] = $this->normalizeHeaderName($header);
        return $this;
    }
67102
public function context($context = null)
    {
        if (is_null($context) || empty($context) || $context == "this") {
            $context = null;
        } else {
            $this->__contextAwareContext = $context;
        }
        return $this;
    }
327212
public function serialize(SpanContext $context)
    {
        $spanHex = str_pad($context->spanId(), 16, "0", STR_PAD_LEFT);
        $traceOptions = $context->enabled() ? self::OPTION_ENABLED : 0;
        return pack("CCH*CH*CC", 0, 0, $context->traceId(), 1, $spanHex, 2, $traceOptions);
    }
954196
private function getRecordHeaderNode(Header $header)
    {
        $headerNode = $this->response->createElement('header');
        $headerNode->appendChild($this->response->createElement('identifier', $header->getIdentifier()));
        $headerNode->appendChild(
            $this->response->createElement('datestamp', $this->toUtcDateTime($header->getDatestamp()))
        );
        foreach ($header->getSetSpecs() as $setSpec) {
            $headerNode->appendChild($this->response->createElement('setSpec', $setSpec));
        }
        if ($header->isDeleted()) {
            $headerNode->setAttribute("status", "deleted");
        }
        return $headerNode;
    }
385720
public static SpanContext extractSpanContext(Headers headers, Tracer tracer) {
    return tracer
        .extract(Format.Builtin.TEXT_MAP, new HeadersMapExtractAdapter(headers, true));
  }
335986
public function setHttpHeader($header)
    {
        $headers = $this->getHttpHeaders();
        $headers[] = $header;
        $this->setHttpHeaders($headers);

    }
63635
public static function decode($header)
    {
        $data = [
            'realm'    => null,
            'username' => null,
            'uri'      => null,
            'nonce'    => null,
            'opaque'   => null,
            'qop'      => null,
            'cnonce'   => null,
            'nc'       => null,
            'response' => null
        ];
        $keys = implode('|', array_keys($data));
        $regex = '~(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))~';
        preg_match_all($regex, $header, $matches, PREG_SET_ORDER);

        foreach ($matches as $m) {
            $data[$m[1]] = $m[3] ? $m[3] : $m[4];
        }
        return $data;
    }
1053508
protected function getHeaderAdditions($header)
    {
        $insert = '';
        if ($this->injectDate) {
            $insert .= $this
                ->createTag($this->injectDate, (string)$header->datestamp);
        }
        if (isset($header->setSpec)
            && ($this->injectSetSpec || $this->injectSetName)
        ) {
            $insert .= $this->getHeaderSetAdditions($header->setSpec);
        }
        if ($this->injectHeaderElements) {
            foreach ($this->injectHeaderElements as $element) {
                if (isset($header->$element)) {
                    $insert .= $header->$element->asXML();
                }
            }
        }
        return $insert;
    }
236737
function replace($header)
    {
        if (is_string($header))
            $header = HeaderField::fromString($header);

        return $this
            ->remove($header->getName())
            ->add($header);
    }