metadata[$key] ?? $default; } /** * Get config value */ public function getConfig(string $key, mixed $default = null): mixed { return $this->config[$key] ?? $default; } /** * Create context with updated metadata */ public function withMetadata(array $metadata): self { return new self( tenantId: $this->tenantId, userIdentifier: $this->userIdentifier, userIdentity: $this->userIdentity, metadata: $metadata, config: $this->config, ); } /** * Create context with user identifier set */ public function withUserIdentifier(string $userIdentifier): self { return new self( tenantId: $this->tenantId, userIdentifier: $userIdentifier, userIdentity: $this->userIdentity, metadata: $this->metadata, config: $this->config, ); } }