Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Baggage.php

class Baggage

Hierarchy

  • class \OpenTelemetry\API\Baggage\Baggage implements \OpenTelemetry\API\Baggage\BaggageInterface

Expanded class hierarchy of Baggage

1 file declares its use of Baggage
BaggagePropagator.php in vendor/open-telemetry/api/Baggage/Propagation/BaggagePropagator.php

File

vendor/open-telemetry/api/Baggage/Baggage.php, line 12

Namespace

OpenTelemetry\API\Baggage
View source
final class Baggage implements BaggageInterface {
    private static ?self $emptyBaggage = null;
    
    /** @inheritDoc */
    public static function fromContext(ContextInterface $context) : BaggageInterface {
        return $context->get(ContextKeys::baggage()) ?? self::getEmpty();
    }
    
    /** @inheritDoc */
    public static function getBuilder() : BaggageBuilderInterface {
        return new BaggageBuilder();
    }
    
    /** @inheritDoc */
    public static function getCurrent() : BaggageInterface {
        return self::fromContext(Context::getCurrent());
    }
    
    /** @inheritDoc */
    public static function getEmpty() : BaggageInterface {
        if (null === self::$emptyBaggage) {
            self::$emptyBaggage = new self();
        }
        return self::$emptyBaggage;
    }
    
    /** @param array<string, Entry> $entries */
    public function __construct(array $entries = []) {
    }
    
    /** @inheritDoc */
    public function activate() : ScopeInterface {
        return Context::getCurrent()->withContextValue($this)
            ->activate();
    }
    
    /** @inheritDoc */
    public function getEntry(string $key) : ?Entry {
        return $this->entries[$key] ?? null;
    }
    
    /** @inheritDoc */
    public function getValue(string $key) {
        if (($entry = $this->getEntry($key)) !== null) {
            return $entry->getValue();
        }
        return null;
    }
    
    /** @inheritDoc */
    public function getAll() : iterable {
        foreach ($this->entries as $key => $entry) {
            (yield $key => $entry);
        }
    }
    
    /** @inheritDoc */
    public function isEmpty() : bool {
        return $this->entries === [];
    }
    
    /** @inheritDoc */
    public function toBuilder() : BaggageBuilderInterface {
        return new BaggageBuilder($this->entries);
    }
    
    /** @inheritDoc */
    public function storeInContext(ContextInterface $context) : ContextInterface {
        return $context->with(ContextKeys::baggage(), $this);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Baggage::$emptyBaggage private static property
Baggage::activate public function @inheritDoc Overrides ImplicitContextKeyedInterface::activate
Baggage::fromContext public static function @inheritDoc Overrides BaggageInterface::fromContext
Baggage::getAll public function @inheritDoc Overrides BaggageInterface::getAll
Baggage::getBuilder public static function @inheritDoc Overrides BaggageInterface::getBuilder
Baggage::getCurrent public static function @inheritDoc Overrides BaggageInterface::getCurrent
Baggage::getEmpty public static function @inheritDoc Overrides BaggageInterface::getEmpty
Baggage::getEntry public function @inheritDoc Overrides BaggageInterface::getEntry
Baggage::getValue public function @inheritDoc Overrides BaggageInterface::getValue
Baggage::isEmpty public function @inheritDoc Overrides BaggageInterface::isEmpty
Baggage::storeInContext public function @inheritDoc Overrides ImplicitContextKeyedInterface::storeInContext
Baggage::toBuilder public function @inheritDoc Overrides BaggageInterface::toBuilder
Baggage::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal