Laravel AT Protocol Client (alpha & unstable)
at main 39 lines 1.1 kB view raw
1<?php 2 3namespace SocialDept\AtpClient\Data\Responses\Bsky\Graph; 4 5use Illuminate\Contracts\Support\Arrayable; 6use Illuminate\Support\Collection; 7use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileView; 8 9/** 10 * @implements Arrayable<string, mixed> 11 */ 12class GetSuggestedFollowsByActorResponse implements Arrayable 13{ 14 /** 15 * @param Collection<int, ProfileView> $suggestions 16 */ 17 public function __construct( 18 public readonly Collection $suggestions, 19 public readonly ?bool $isFallback = null, 20 ) {} 21 22 public static function fromArray(array $data): self 23 { 24 return new self( 25 suggestions: collect($data['suggestions'] ?? [])->map( 26 fn (array $profile) => ProfileView::fromArray($profile) 27 ), 28 isFallback: $data['isFallback'] ?? null, 29 ); 30 } 31 32 public function toArray(): array 33 { 34 return [ 35 'suggestions' => $this->suggestions->map(fn (ProfileView $p) => $p->toArray())->all(), 36 'isFallback' => $this->isFallback, 37 ]; 38 } 39}