WordPress\AiClient\Builders

MessageBuilder::__clonepublicWP 0.4.2

Creates a deep clone of this builder.

Clones all MessagePart objects in the parts array to ensure the cloned builder is independent of the original.

Method of the class: MessageBuilder{}

No Hooks.

Returns

null. Nothing (null).

Usage

$MessageBuilder = new MessageBuilder();
$MessageBuilder->__clone();

Changelog

Since 0.4.2 Introduced.

MessageBuilder::__clone() code WP 7.0

public function __clone()
{
    // Deep clone parts array (MessagePart has __clone)
    $clonedParts = [];
    foreach ($this->parts as $part) {
        $clonedParts[] = clone $part;
    }
    $this->parts = $clonedParts;
    // Note: $role is an enum value object and can be safely shared
}