GenerativeAiOperation::fromArray( $array )

In this article

{@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

VersionDescription
0.1.0Introduced.

User Contributed Notes

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