Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Wrap Chat Convo response arrays in Laravel Collections

+20 -18
+5 -3
src/Data/Responses/Chat/Convo/GetLogResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Chat\Convo; 4 4 5 + use Illuminate\Support\Collection; 6 + 5 7 class GetLogResponse 6 8 { 7 9 /** 8 - * @param array<mixed> $logs Array of log event objects (LogBeginConvo, LogCreateMessage, etc.) 10 + * @param Collection<int, mixed> $logs Collection of log event objects (LogBeginConvo, LogCreateMessage, etc.) 9 11 */ 10 12 public function __construct( 11 - public readonly array $logs, 13 + public readonly Collection $logs, 12 14 public readonly ?string $cursor = null, 13 15 ) {} 14 16 15 17 public static function fromArray(array $data): self 16 18 { 17 19 return new self( 18 - logs: $data['logs'] ?? [], 20 + logs: collect($data['logs'] ?? []), 19 21 cursor: $data['cursor'] ?? null, 20 22 ); 21 23 }
+5 -5
src/Data/Responses/Chat/Convo/GetMessagesResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Chat\Convo; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\DeletedMessageView; 6 7 use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\MessageView; 7 8 8 9 class GetMessagesResponse 9 10 { 10 11 /** 11 - * @param array<MessageView|DeletedMessageView> $messages 12 + * @param Collection<int, MessageView|DeletedMessageView> $messages 12 13 */ 13 14 public function __construct( 14 - public readonly array $messages, 15 + public readonly Collection $messages, 15 16 public readonly ?string $cursor = null, 16 17 ) {} 17 18 18 19 public static function fromArray(array $data): self 19 20 { 20 21 return new self( 21 - messages: array_map( 22 + messages: collect($data['messages'] ?? [])->map( 22 23 function (array $message) { 23 24 if (isset($message['$type']) && $message['$type'] === 'chat.bsky.convo.defs#deletedMessageView') { 24 25 return DeletedMessageView::fromArray($message); 25 26 } 26 27 27 28 return MessageView::fromArray($message); 28 - }, 29 - $data['messages'] ?? [] 29 + } 30 30 ), 31 31 cursor: $data['cursor'] ?? null, 32 32 );
+5 -5
src/Data/Responses/Chat/Convo/ListConvosResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Chat\Convo; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\ConvoView; 6 7 7 8 class ListConvosResponse 8 9 { 9 10 /** 10 - * @param array<ConvoView> $convos 11 + * @param Collection<int, ConvoView> $convos 11 12 */ 12 13 public function __construct( 13 - public readonly array $convos, 14 + public readonly Collection $convos, 14 15 public readonly ?string $cursor = null, 15 16 ) {} 16 17 17 18 public static function fromArray(array $data): self 18 19 { 19 20 return new self( 20 - convos: array_map( 21 - fn (array $convo) => ConvoView::fromArray($convo), 22 - $data['convos'] ?? [] 21 + convos: collect($data['convos'] ?? [])->map( 22 + fn (array $convo) => ConvoView::fromArray($convo) 23 23 ), 24 24 cursor: $data['cursor'] ?? null, 25 25 );
+5 -5
src/Data/Responses/Chat/Convo/SendMessageBatchResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Chat\Convo; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\MessageView; 6 7 7 8 class SendMessageBatchResponse 8 9 { 9 10 /** 10 - * @param array<MessageView> $items 11 + * @param Collection<int, MessageView> $items 11 12 */ 12 13 public function __construct( 13 - public readonly array $items, 14 + public readonly Collection $items, 14 15 ) {} 15 16 16 17 public static function fromArray(array $data): self 17 18 { 18 19 return new self( 19 - items: array_map( 20 - fn (array $item) => MessageView::fromArray($item), 21 - $data['items'] ?? [] 20 + items: collect($data['items'] ?? [])->map( 21 + fn (array $item) => MessageView::fromArray($item) 22 22 ), 23 23 ); 24 24 }