Laravel AT Protocol Client (alpha & unstable)

Wrap Bsky Feed response arrays in Laravel Collections

+5 -5
src/Data/Responses/Bsky/Feed/GetActorFeedsResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\GeneratorView; 6 7 7 8 class GetActorFeedsResponse 8 9 { 9 10 /** 10 - * @param array<GeneratorView> $feeds 11 + * @param Collection<int, GeneratorView> $feeds 11 12 */ 12 13 public function __construct( 13 - public readonly array $feeds, 14 + public readonly Collection $feeds, 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 - feeds: array_map( 21 - fn (array $feed) => GeneratorView::fromArray($feed), 22 - $data['feeds'] ?? [] 21 + feeds: collect($data['feeds'] ?? [])->map( 22 + fn (array $feed) => GeneratorView::fromArray($feed) 23 23 ), 24 24 cursor: $data['cursor'] ?? null, 25 25 );
+5 -5
src/Data/Responses/Bsky/Feed/GetActorLikesResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\FeedViewPost; 6 7 7 8 class GetActorLikesResponse 8 9 { 9 10 /** 10 - * @param array<FeedViewPost> $feed 11 + * @param Collection<int, FeedViewPost> $feed 11 12 */ 12 13 public function __construct( 13 - public readonly array $feed, 14 + public readonly Collection $feed, 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 - feed: array_map( 21 - fn (array $post) => FeedViewPost::fromArray($post), 22 - $data['feed'] ?? [] 21 + feed: collect($data['feed'] ?? [])->map( 22 + fn (array $post) => FeedViewPost::fromArray($post) 23 23 ), 24 24 cursor: $data['cursor'] ?? null, 25 25 );
+5 -5
src/Data/Responses/Bsky/Feed/GetAuthorFeedResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\FeedViewPost; 6 7 7 8 class GetAuthorFeedResponse 8 9 { 9 10 /** 10 - * @param array<FeedViewPost> $feed 11 + * @param Collection<int, FeedViewPost> $feed 11 12 */ 12 13 public function __construct( 13 - public readonly array $feed, 14 + public readonly Collection $feed, 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 - feed: array_map( 21 - fn (array $post) => FeedViewPost::fromArray($post), 22 - $data['feed'] ?? [] 21 + feed: collect($data['feed'] ?? [])->map( 22 + fn (array $post) => FeedViewPost::fromArray($post) 23 23 ), 24 24 cursor: $data['cursor'] ?? null, 25 25 );
+5 -5
src/Data/Responses/Bsky/Feed/GetFeedGeneratorsResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\GeneratorView; 6 7 7 8 class GetFeedGeneratorsResponse 8 9 { 9 10 /** 10 - * @param array<GeneratorView> $feeds 11 + * @param Collection<int, GeneratorView> $feeds 11 12 */ 12 13 public function __construct( 13 - public readonly array $feeds, 14 + public readonly Collection $feeds, 14 15 ) {} 15 16 16 17 public static function fromArray(array $data): self 17 18 { 18 19 return new self( 19 - feeds: array_map( 20 - fn (array $feed) => GeneratorView::fromArray($feed), 21 - $data['feeds'] ?? [] 20 + feeds: collect($data['feeds'] ?? [])->map( 21 + fn (array $feed) => GeneratorView::fromArray($feed) 22 22 ), 23 23 ); 24 24 }
+5 -5
src/Data/Responses/Bsky/Feed/GetFeedResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\FeedViewPost; 6 7 7 8 class GetFeedResponse 8 9 { 9 10 /** 10 - * @param array<FeedViewPost> $feed 11 + * @param Collection<int, FeedViewPost> $feed 11 12 */ 12 13 public function __construct( 13 - public readonly array $feed, 14 + public readonly Collection $feed, 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 - feed: array_map( 21 - fn (array $post) => FeedViewPost::fromArray($post), 22 - $data['feed'] ?? [] 21 + feed: collect($data['feed'] ?? [])->map( 22 + fn (array $post) => FeedViewPost::fromArray($post) 23 23 ), 24 24 cursor: $data['cursor'] ?? null, 25 25 );
+5 -5
src/Data/Responses/Bsky/Feed/GetLikesResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\GetLikes\Like; 6 7 7 8 class GetLikesResponse 8 9 { 9 10 /** 10 - * @param array<Like> $likes 11 + * @param Collection<int, Like> $likes 11 12 */ 12 13 public function __construct( 13 14 public readonly string $uri, 14 - public readonly array $likes, 15 + public readonly Collection $likes, 15 16 public readonly ?string $cid = null, 16 17 public readonly ?string $cursor = null, 17 18 ) {} ··· 20 21 { 21 22 return new self( 22 23 uri: $data['uri'], 23 - likes: array_map( 24 - fn (array $like) => Like::fromArray($like), 25 - $data['likes'] ?? [] 24 + likes: collect($data['likes'] ?? [])->map( 25 + fn (array $like) => Like::fromArray($like) 26 26 ), 27 27 cid: $data['cid'] ?? null, 28 28 cursor: $data['cursor'] ?? null,
+5 -5
src/Data/Responses/Bsky/Feed/GetPostsResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\PostView; 6 7 7 8 class GetPostsResponse 8 9 { 9 10 /** 10 - * @param array<PostView> $posts 11 + * @param Collection<int, PostView> $posts 11 12 */ 12 13 public function __construct( 13 - public readonly array $posts, 14 + public readonly Collection $posts, 14 15 ) {} 15 16 16 17 public static function fromArray(array $data): self 17 18 { 18 19 return new self( 19 - posts: array_map( 20 - fn (array $post) => PostView::fromArray($post), 21 - $data['posts'] ?? [] 20 + posts: collect($data['posts'] ?? [])->map( 21 + fn (array $post) => PostView::fromArray($post) 22 22 ), 23 23 ); 24 24 }
+5 -5
src/Data/Responses/Bsky/Feed/GetQuotesResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\PostView; 6 7 7 8 class GetQuotesResponse 8 9 { 9 10 /** 10 - * @param array<PostView> $posts 11 + * @param Collection<int, PostView> $posts 11 12 */ 12 13 public function __construct( 13 14 public readonly string $uri, 14 - public readonly array $posts, 15 + public readonly Collection $posts, 15 16 public readonly ?string $cid = null, 16 17 public readonly ?string $cursor = null, 17 18 ) {} ··· 20 21 { 21 22 return new self( 22 23 uri: $data['uri'], 23 - posts: array_map( 24 - fn (array $post) => PostView::fromArray($post), 25 - $data['posts'] ?? [] 24 + posts: collect($data['posts'] ?? [])->map( 25 + fn (array $post) => PostView::fromArray($post) 26 26 ), 27 27 cid: $data['cid'] ?? null, 28 28 cursor: $data['cursor'] ?? null,
+5 -5
src/Data/Responses/Bsky/Feed/GetRepostedByResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileView; 6 7 7 8 class GetRepostedByResponse 8 9 { 9 10 /** 10 - * @param array<ProfileView> $repostedBy 11 + * @param Collection<int, ProfileView> $repostedBy 11 12 */ 12 13 public function __construct( 13 14 public readonly string $uri, 14 - public readonly array $repostedBy, 15 + public readonly Collection $repostedBy, 15 16 public readonly ?string $cid = null, 16 17 public readonly ?string $cursor = null, 17 18 ) {} ··· 20 21 { 21 22 return new self( 22 23 uri: $data['uri'], 23 - repostedBy: array_map( 24 - fn (array $profile) => ProfileView::fromArray($profile), 25 - $data['repostedBy'] ?? [] 24 + repostedBy: collect($data['repostedBy'] ?? [])->map( 25 + fn (array $profile) => ProfileView::fromArray($profile) 26 26 ), 27 27 cid: $data['cid'] ?? null, 28 28 cursor: $data['cursor'] ?? null,
+5 -5
src/Data/Responses/Bsky/Feed/GetSuggestedFeedsResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\GeneratorView; 6 7 7 8 class GetSuggestedFeedsResponse 8 9 { 9 10 /** 10 - * @param array<GeneratorView> $feeds 11 + * @param Collection<int, GeneratorView> $feeds 11 12 */ 12 13 public function __construct( 13 - public readonly array $feeds, 14 + public readonly Collection $feeds, 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 - feeds: array_map( 21 - fn (array $feed) => GeneratorView::fromArray($feed), 22 - $data['feeds'] ?? [] 21 + feeds: collect($data['feeds'] ?? [])->map( 22 + fn (array $feed) => GeneratorView::fromArray($feed) 23 23 ), 24 24 cursor: $data['cursor'] ?? null, 25 25 );
+5 -5
src/Data/Responses/Bsky/Feed/GetTimelineResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\FeedViewPost; 6 7 7 8 class GetTimelineResponse 8 9 { 9 10 /** 10 - * @param array<FeedViewPost> $feed 11 + * @param Collection<int, FeedViewPost> $feed 11 12 */ 12 13 public function __construct( 13 - public readonly array $feed, 14 + public readonly Collection $feed, 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 - feed: array_map( 21 - fn (array $post) => FeedViewPost::fromArray($post), 22 - $data['feed'] ?? [] 21 + feed: collect($data['feed'] ?? [])->map( 22 + fn (array $post) => FeedViewPost::fromArray($post) 23 23 ), 24 24 cursor: $data['cursor'] ?? null, 25 25 );
+5 -5
src/Data/Responses/Bsky/Feed/SearchPostsResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Bsky\Feed; 4 4 5 + use Illuminate\Support\Collection; 5 6 use SocialDept\AtpSchema\Generated\App\Bsky\Feed\Defs\PostView; 6 7 7 8 class SearchPostsResponse 8 9 { 9 10 /** 10 - * @param array<PostView> $posts 11 + * @param Collection<int, PostView> $posts 11 12 */ 12 13 public function __construct( 13 - public readonly array $posts, 14 + public readonly Collection $posts, 14 15 public readonly ?string $cursor = null, 15 16 public readonly ?int $hitsTotal = null, 16 17 ) {} ··· 18 19 public static function fromArray(array $data): self 19 20 { 20 21 return new self( 21 - posts: array_map( 22 - fn (array $post) => PostView::fromArray($post), 23 - $data['posts'] ?? [] 22 + posts: collect($data['posts'] ?? [])->map( 23 + fn (array $post) => PostView::fromArray($post) 24 24 ), 25 25 cursor: $data['cursor'] ?? null, 26 26 hitsTotal: $data['hitsTotal'] ?? null,