{@inheritdoc}

@param SpanContext $spanContext
@param string $format
@param mixed $carrier
@return void

@throws UnsupportedFormat
162394
public function inject(OTSpanContext $spanContext, $format, &$carrier)
    {
        if ($spanContext instanceof SpanContext) {
            $codec = $this->codecs[$format] ?? null;

            if ($codec == null) {
                throw UnsupportedFormat::forFormat(is_scalar($format) ? $format : gettype($format));
            }


            $codec->inject($spanContext, $carrier);
            return;
        }

        $message = sprintf(
            'Invalid span context. Expected Jaeger\SpanContext, got %s.',
            is_object($spanContext) ? get_class($spanContext) : gettype($spanContext)
        );

        $this->logger->warning($message);
    }
599132
public function extract($format, $carrier){
        if($format == Formats\TEXT_MAP){
            return $this->propagator->extract($format, $carrier);
        }else{
            throw new \Exception("not support format");
        }
    }
462831
public function format($format = null)
    {
        if (!$format) {
            $format = $this->getFormat();
        }

        return parent::format($format ?: static::$toStringFormat);
    }
419473
public function setDefaultStringFormat($format)
    {
        $formats = static::getSupportedStringFormats();

        $format = strtoupper($format);
        if (!in_array($format, $formats)) {
            throw new InvalidArgumentException(sprintf('Given "%s" default string format is not supported. Only "%s" are valid string formats.', $format, implode(', ', $formats)));
        }

        $this->defaultStringFormat = $format;
    }
438335
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public SpanContext toFromBinarySpanContext(Data data) throws SpanContextParseException {
    return data.binaryFormat.fromByteArray(data.binaryFormat.toByteArray(data.spanContext));
  }
88025
public function normalize($stream, $format = null, array $context = array())
    {
        $string = stream_get_contents($stream);

        return parent::normalize($string, $format, $context);
    }
632319
public function setFormat($format)
    {
        if (in_array($format, TextFormat::asArray()) === true) {
            $this->format = $format;
        } else {
            $msg = "The 'format' argument must be a value from the TextFormat enumeration, '" . gettype($format) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
709379
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
    {
        if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
            $parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
        } else {
            unset($parentContext[self::ATTRIBUTES]);
        }

        return $parentContext;
    }
852402
public static void propagateTracingContext(Span span, HttpHeaders headers) {
    Preconditions.checkArgument(span != null, "span should not be null.");
    Preconditions.checkArgument(headers != null, "headers should not be null.");
    if (propagationTextFormat != null && propagationTextFormatSetter != null) {
      if (!span.equals(BlankSpan.INSTANCE)) {
        propagationTextFormat.inject(span.getContext(), headers, propagationTextFormatSetter);
      }
    }
  }
947275
def inject(span_context, format, carrier)
      case format
      when OpenTracing::FORMAT_TEXT_MAP
        inject_to_text_map(span_context, carrier)
      when OpenTracing::FORMAT_BINARY
        warn 'Binary inject format not yet implemented'
      when OpenTracing::FORMAT_RACK
        inject_to_rack(span_context, carrier)
      else
        warn 'Unknown inject format'
      end
    end
984600
public function setFormat($format)
    {
        if (!in_array($format, $this->formats)) {
            $msg = "The '%s' format is not allowed. Try with '%s'";
            throw new InvalidArgumentException(sprintf($msg, $format, implode("', '", $this->formats)));
        }

        $this->format = $format;

        return $this;
    }
994203
public function format(string $format) : self
    {
        if (! in_array($format, self::VALID_FORMATS)) {
            throw new Exception('Invalid format provided to path.');
        }

        $this->format = $format;

        return $this;
    }
533280
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public SpanContext fromBinarySpanContext(Data data) throws SpanContextParseException {
    return data.binaryFormat.fromByteArray(data.spanContextBinary);
  }
1310233
public function extract($carrier)
    {
        $traceId = "0";
        $spanId = "0";
        $parentId = "0";
        $flags = 0;

        if (isset($carrier[strtolower(self::SAMPLED_NAME)])) {
            if ($carrier[strtolower(self::SAMPLED_NAME)] === "1" ||
                strtolower($carrier[strtolower(self::SAMPLED_NAME)] === "true")
            ) {
                $flags = $flags | SAMPLED_FLAG;
            }
        }

        if (isset($carrier[strtolower(self::TRACE_ID_NAME)])) {
            $traceId =  CodecUtility::hexToInt64($carrier[strtolower(self::TRACE_ID_NAME)], 16, 10);
        }

        if (isset($carrier[strtolower(self::PARENT_ID_NAME)])) {
            $parentId =  CodecUtility::hexToInt64($carrier[strtolower(self::PARENT_ID_NAME)], 16, 10);
        }

        if (isset($carrier[strtolower(self::SPAN_ID_NAME)])) {
            $spanId =  CodecUtility::hexToInt64($carrier[strtolower(self::SPAN_ID_NAME)], 16, 10);
        }

        if (isset($carrier[strtolower(self::FLAGS_NAME)])) {
            if ($carrier[strtolower(self::FLAGS_NAME)] === "1") {
                $flags = $flags | DEBUG_FLAG;
            }
        }

        if ($traceId != "0" && $spanId != "0") {
            return new SpanContext($traceId, $spanId, $parentId, $flags);
        }

        return null;
    }
483408
public function supportsNormalization($data, $format = null): bool
    {
        if (true === \is_object($data))
        {
            $class = \get_class($data);

            if (false === isset($this->localStorage[$class]))
            {
                $this->localStorage[$class] = \array_map(
                    static function(\ReflectionProperty $property): string
                    {
                        return (string) $property->name;
                    },
                    (new \ReflectionClass($data))->getProperties()
                );
            }

            return empty($this->localStorage[$class]);
        }

        return false;
    }
972219
public function inject(SpanContext $spanContext, &$carrier)
    {
        $carrier[self::TRACE_ID_NAME] = dechex($spanContext->getTraceId());
        $carrier[self::SPAN_ID_NAME] = dechex($spanContext->getSpanId());
        if ($spanContext->getParentId() != null) {
            $carrier[self::PARENT_ID_NAME] = dechex($spanContext->getParentId());
        }
        $carrier[self::FLAGS_NAME] = (int) $spanContext->getFlags();
    }
865888
public function render($format = null)
    {
        if ( ! is_null($format) )
            $this->setFormat($format);

        $this->setHeaderResponse();
        call_user_func($this->getFunctionName(), $this->getImage());
    }