metadata[$key] = $value; return $new; } public function getMetadata(string $key, mixed $default = null): mixed { return $this->metadata[$key] ?? $default; } public function hasMetadata(string $key): bool { return array_key_exists($key, $this->metadata); } }