}> */ final class ThreadMessageResponseContentText implements ResponseContract { /** * @use ArrayAccessible}> */ use ArrayAccessible; use Fakeable; /** * @param array $annotations */ private function __construct( public string $value, public array $annotations, ) { } /** * Acts as static factory, and returns a new Response instance. * * @param array{value: string, annotations: array} $attributes */ public static function from(array $attributes): self { $annotations = array_map( fn (array $annotation): ThreadMessageResponseContentTextAnnotationFileCitationObject|ThreadMessageResponseContentTextAnnotationFilePathObject => match ($annotation['type']) { 'file_citation' => ThreadMessageResponseContentTextAnnotationFileCitationObject::from($annotation), 'file_path' => ThreadMessageResponseContentTextAnnotationFilePathObject::from($annotation), }, $attributes['annotations'], ); return new self( $attributes['value'], $annotations, ); } /** * {@inheritDoc} */ public function toArray(): array { return [ 'value' => $this->value, 'annotations' => array_map( fn (ThreadMessageResponseContentTextAnnotationFilePathObject|ThreadMessageResponseContentTextAnnotationFileCitationObject $annotation): array => $annotation->toArray(), $this->annotations, ), ]; } }