function ArrayAccessGetterSetter::get
Overrides PropagationGetterInterface::get
File
-
vendor/
open-telemetry/ context/ Propagation/ ArrayAccessGetterSetter.php, line 59
Class
- ArrayAccessGetterSetter
- Default implementation of {This type is used if no custom getter/setter is provided to {
Namespace
OpenTelemetry\Context\PropagationCode
public function get($carrier, string $key) : ?string {
if ($this->isSupportedCarrier($carrier)) {
$value = $carrier[$this->resolveKey($carrier, $key)] ?? null;
if (is_array($value) && $value) {
$value = $value[array_key_first($value)];
}
return is_string($value) ? $value : null;
}
throw new InvalidArgumentException(sprintf('Unsupported carrier type: %s. Unable to get value associated with key:%s', get_debug_type($carrier), $key));
}