MessageBuilder::__clone()

In this article

Creates a deep clone of this builder.

Description

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

Source

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
}

Changelog

VersionDescription
0.4.2Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.