Laravel AT Protocol Client (alpha & unstable)
at dev 36 lines 878 B view raw
1<?php 2 3namespace SocialDept\AtpClient\Data\Responses\Chat\Convo; 4 5use Illuminate\Contracts\Support\Arrayable; 6use Illuminate\Support\Collection; 7use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\MessageView; 8 9/** 10 * @implements Arrayable<string, mixed> 11 */ 12class SendMessageBatchResponse implements Arrayable 13{ 14 /** 15 * @param Collection<int, MessageView> $items 16 */ 17 public function __construct( 18 public readonly Collection $items, 19 ) {} 20 21 public static function fromArray(array $data): self 22 { 23 return new self( 24 items: collect($data['items'] ?? [])->map( 25 fn (array $item) => MessageView::fromArray($item) 26 ), 27 ); 28 } 29 30 public function toArray(): array 31 { 32 return [ 33 'items' => $this->items->map(fn (MessageView $m) => $m->toArray())->all(), 34 ]; 35 } 36}