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