Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 57 lines 1.3 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\App\Bsky\Embed; 4 5use SocialDept\AtpSchema\Data\Data; 6use SocialDept\AtpSchema\Support\UnionHelper; 7 8/** 9 * GENERATED CODE - DO NOT EDIT 10 * 11 * A representation of a record embedded in a Bluesky record (eg, a post), 12 * alongside other compatible embeds. For example, a quote post and image, or a 13 * quote post and external URL card. 14 * 15 * Lexicon: app.bsky.embed.recordWithMedia 16 * Type: object 17 * 18 * @property Record $record 19 * @property mixed $media 20 * 21 * Constraints: 22 * - Required: record, media 23 */ 24class RecordWithMedia extends Data 25{ 26 public function __construct( 27 public readonly Record $record, 28 public readonly mixed $media 29 ) { 30 } 31 32 /** 33 * Get the lexicon NSID for this data type. 34 * 35 * @return string 36 */ 37 public static function getLexicon(): string 38 { 39 return 'app.bsky.embed.recordWithMedia'; 40 } 41 42 43 /** 44 * Create an instance from an array. 45 * 46 * @param array $data The data array 47 * @return static 48 */ 49 public static function fromArray(array $data): static 50 { 51 return new static( 52 record: Record::fromArray($data['record']), 53 media: UnionHelper::validateOpenUnion($data['media']) 54 ); 55 } 56 57}