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