Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 74 lines 2.0 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\App\Bsky\Labeler\Defs; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileView; 8use SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs\Label; 9 10/** 11 * GENERATED CODE - DO NOT EDIT 12 * 13 * Lexicon: app.bsky.labeler.defs.labelerView 14 * Type: object 15 * 16 * @property string $uri 17 * @property string $cid 18 * @property ProfileView $creator 19 * @property int|null $likeCount 20 * @property mixed $viewer 21 * @property Carbon $indexedAt 22 * @property array<Label>|null $labels 23 * 24 * Constraints: 25 * - Required: uri, cid, creator, indexedAt 26 * - uri: Format: at-uri 27 * - cid: Format: cid 28 * - likeCount: Minimum: 0 29 * - indexedAt: Format: datetime 30 */ 31class LabelerView extends Data 32{ 33 public function __construct( 34 public readonly string $uri, 35 public readonly string $cid, 36 public readonly ProfileView $creator, 37 public readonly Carbon $indexedAt, 38 public readonly ?int $likeCount = null, 39 public readonly mixed $viewer = null, 40 public readonly ?array $labels = null 41 ) { 42 } 43 44 /** 45 * Get the lexicon NSID for this data type. 46 * 47 * @return string 48 */ 49 public static function getLexicon(): string 50 { 51 return 'app.bsky.labeler.defs.labelerView'; 52 } 53 54 55 /** 56 * Create an instance from an array. 57 * 58 * @param array $data The data array 59 * @return static 60 */ 61 public static function fromArray(array $data): static 62 { 63 return new static( 64 uri: $data['uri'], 65 cid: $data['cid'], 66 creator: ProfileView::fromArray($data['creator']), 67 indexedAt: Carbon::parse($data['indexedAt']), 68 likeCount: $data['likeCount'] ?? null, 69 viewer: $data['viewer'] ?? null, 70 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [] 71 ); 72 } 73 74}