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