WordPress\AiClient\Results\DTO
GenerativeAiResult::__clone
Performs a deep clone of the result.
This method ensures that all nested objects (candidates, token usage, metadata) are cloned to prevent modifications to the cloned result from affecting the original.
Method of the class: GenerativeAiResult{}
No Hooks.
Returns
null. Nothing (null).
Usage
$GenerativeAiResult = new GenerativeAiResult(); $GenerativeAiResult->__clone();
Changelog
| Since 0.4.2 | Introduced. |
GenerativeAiResult::__clone() GenerativeAiResult:: clone code WP 7.0
public function __clone()
{
$clonedCandidates = [];
foreach ($this->candidates as $candidate) {
$clonedCandidates[] = clone $candidate;
}
$this->candidates = $clonedCandidates;
$this->tokenUsage = clone $this->tokenUsage;
$this->providerMetadata = clone $this->providerMetadata;
$this->modelMetadata = clone $this->modelMetadata;
}