{@inheritDoc}
Source
public static function fromArray(array $array): self
{
static::validateFromArrayData($array, [self::KEY_ID, self::KEY_STATE]);
$state = OperationStateEnum::from($array[self::KEY_STATE]);
if ($state->isSucceeded()) {
// If the operation has succeeded, it must have a result
static::validateFromArrayData($array, [self::KEY_RESULT]);
}
$result = null;
if (isset($array[self::KEY_RESULT])) {
$result = GenerativeAiResult::fromArray($array[self::KEY_RESULT]);
}
return new self($array[self::KEY_ID], $state, $result);
}
Changelog
| Version | Description |
|---|---|
| 0.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.