Laravel AT Protocol Client (alpha & unstable)

Add Arrayable interface to Atproto Repo response classes

+87 -6
+15 -1
src/Data/Responses/Atproto/Repo/CreateRecordResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Atproto\Repo; 4 4 5 + use Illuminate\Contracts\Support\Arrayable; 5 6 use SocialDept\AtpSchema\Generated\Com\Atproto\Repo\Defs\CommitMeta; 6 7 7 - class CreateRecordResponse 8 + /** 9 + * @implements Arrayable<string, mixed> 10 + */ 11 + class CreateRecordResponse implements Arrayable 8 12 { 9 13 public function __construct( 10 14 public readonly string $uri, ··· 21 25 commit: isset($data['commit']) ? CommitMeta::fromArray($data['commit']) : null, 22 26 validationStatus: $data['validationStatus'] ?? null, 23 27 ); 28 + } 29 + 30 + public function toArray(): array 31 + { 32 + return [ 33 + 'uri' => $this->uri, 34 + 'cid' => $this->cid, 35 + 'commit' => $this->commit?->toArray(), 36 + 'validationStatus' => $this->validationStatus, 37 + ]; 24 38 } 25 39 }
+12 -1
src/Data/Responses/Atproto/Repo/DeleteRecordResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Atproto\Repo; 4 4 5 + use Illuminate\Contracts\Support\Arrayable; 5 6 use SocialDept\AtpSchema\Generated\Com\Atproto\Repo\Defs\CommitMeta; 6 7 7 - class DeleteRecordResponse 8 + /** 9 + * @implements Arrayable<string, mixed> 10 + */ 11 + class DeleteRecordResponse implements Arrayable 8 12 { 9 13 public function __construct( 10 14 public readonly ?CommitMeta $commit = null, ··· 15 19 return new self( 16 20 commit: isset($data['commit']) ? CommitMeta::fromArray($data['commit']) : null, 17 21 ); 22 + } 23 + 24 + public function toArray(): array 25 + { 26 + return [ 27 + 'commit' => $this->commit?->toArray(), 28 + ]; 18 29 } 19 30 }
+17 -1
src/Data/Responses/Atproto/Repo/DescribeRepoResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Atproto\Repo; 4 4 5 - class DescribeRepoResponse 5 + use Illuminate\Contracts\Support\Arrayable; 6 + 7 + /** 8 + * @implements Arrayable<string, mixed> 9 + */ 10 + class DescribeRepoResponse implements Arrayable 6 11 { 7 12 /** 8 13 * @param array<string> $collections ··· 24 29 collections: $data['collections'] ?? [], 25 30 handleIsCorrect: $data['handleIsCorrect'], 26 31 ); 32 + } 33 + 34 + public function toArray(): array 35 + { 36 + return [ 37 + 'handle' => $this->handle, 38 + 'did' => $this->did, 39 + 'didDoc' => $this->didDoc, 40 + 'collections' => $this->collections, 41 + 'handleIsCorrect' => $this->handleIsCorrect, 42 + ]; 27 43 } 28 44 }
+15 -1
src/Data/Responses/Atproto/Repo/GetRecordResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Atproto\Repo; 4 4 5 - class GetRecordResponse 5 + use Illuminate\Contracts\Support\Arrayable; 6 + 7 + /** 8 + * @implements Arrayable<string, mixed> 9 + */ 10 + class GetRecordResponse implements Arrayable 6 11 { 7 12 public function __construct( 8 13 public readonly string $uri, ··· 17 22 value: $data['value'], 18 23 cid: $data['cid'] ?? null, 19 24 ); 25 + } 26 + 27 + public function toArray(): array 28 + { 29 + return [ 30 + 'uri' => $this->uri, 31 + 'value' => $this->value, 32 + 'cid' => $this->cid, 33 + ]; 20 34 } 21 35 }
+13 -1
src/Data/Responses/Atproto/Repo/ListRecordsResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Atproto\Repo; 4 4 5 + use Illuminate\Contracts\Support\Arrayable; 5 6 use Illuminate\Support\Collection; 6 7 7 - class ListRecordsResponse 8 + /** 9 + * @implements Arrayable<string, mixed> 10 + */ 11 + class ListRecordsResponse implements Arrayable 8 12 { 9 13 /** 10 14 * @param Collection<int, array{uri: string, cid: string, value: mixed}> $records ··· 20 24 records: collect($data['records'] ?? []), 21 25 cursor: $data['cursor'] ?? null, 22 26 ); 27 + } 28 + 29 + public function toArray(): array 30 + { 31 + return [ 32 + 'records' => $this->records->all(), 33 + 'cursor' => $this->cursor, 34 + ]; 23 35 } 24 36 }
+15 -1
src/Data/Responses/Atproto/Repo/PutRecordResponse.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Data\Responses\Atproto\Repo; 4 4 5 + use Illuminate\Contracts\Support\Arrayable; 5 6 use SocialDept\AtpSchema\Generated\Com\Atproto\Repo\Defs\CommitMeta; 6 7 7 - class PutRecordResponse 8 + /** 9 + * @implements Arrayable<string, mixed> 10 + */ 11 + class PutRecordResponse implements Arrayable 8 12 { 9 13 public function __construct( 10 14 public readonly string $uri, ··· 21 25 commit: isset($data['commit']) ? CommitMeta::fromArray($data['commit']) : null, 22 26 validationStatus: $data['validationStatus'] ?? null, 23 27 ); 28 + } 29 + 30 + public function toArray(): array 31 + { 32 + return [ 33 + 'uri' => $this->uri, 34 + 'cid' => $this->cid, 35 + 'commit' => $this->commit?->toArray(), 36 + 'validationStatus' => $this->validationStatus, 37 + ]; 24 38 } 25 39 }