Laravel AT Protocol Client (alpha & unstable)
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 GetFollowsResponse implements Arrayable
13{
14 /**
15 * @param Collection<int, ProfileView> $follows
16 */
17 public function __construct(
18 public readonly ProfileView $subject,
19 public readonly Collection $follows,
20 public readonly ?string $cursor = null,
21 ) {}
22
23 public static function fromArray(array $data): self
24 {
25 return new self(
26 subject: ProfileView::fromArray($data['subject']),
27 follows: collect($data['follows'] ?? [])->map(
28 fn (array $profile) => ProfileView::fromArray($profile)
29 ),
30 cursor: $data['cursor'] ?? null,
31 );
32 }
33
34 public function toArray(): array
35 {
36 return [
37 'subject' => $this->subject->toArray(),
38 'follows' => $this->follows->map(fn (ProfileView $p) => $p->toArray())->all(),
39 'cursor' => $this->cursor,
40 ];
41 }
42}