MessagePart::__clone()

In this article

Performs a deep clone of the message part.

Description

This method ensures that nested objects (file, function call, function response) are cloned to prevent modifications to the cloned part from affecting the original.

Source

public function __clone()
{
    if ($this->file !== null) {
        $this->file = clone $this->file;
    }
    if ($this->functionCall !== null) {
        $this->functionCall = clone $this->functionCall;
    }
    if ($this->functionResponse !== null) {
        $this->functionResponse = clone $this->functionResponse;
    }
}

Changelog

VersionDescription
0.4.2Introduced.

User Contributed Notes

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