Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at dev 67 lines 1.6 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\App\Bsky\Embed\Video; 4 5use SocialDept\AtpSchema\Data\Data; 6use SocialDept\AtpSchema\Generated\App\Bsky\Embed\Defs\AspectRatio; 7 8/** 9 * GENERATED CODE - DO NOT EDIT 10 * 11 * Lexicon: app.bsky.embed.video.view 12 * Type: object 13 * 14 * @property string $cid 15 * @property string $playlist 16 * @property string|null $thumbnail 17 * @property string|null $alt 18 * @property AspectRatio|null $aspectRatio 19 * 20 * Constraints: 21 * - Required: cid, playlist 22 * - cid: Format: cid 23 * - playlist: Format: uri 24 * - thumbnail: Format: uri 25 * - alt: Max length: 10000 26 * - alt: Max graphemes: 1000 27 */ 28class View extends Data 29{ 30 public function __construct( 31 public readonly string $cid, 32 public readonly string $playlist, 33 public readonly ?string $thumbnail = null, 34 public readonly ?string $alt = null, 35 public readonly ?AspectRatio $aspectRatio = null 36 ) { 37 } 38 39 /** 40 * Get the lexicon NSID for this data type. 41 * 42 * @return string 43 */ 44 public static function getLexicon(): string 45 { 46 return 'app.bsky.embed.video.view'; 47 } 48 49 50 /** 51 * Create an instance from an array. 52 * 53 * @param array $data The data array 54 * @return static 55 */ 56 public static function fromArray(array $data): static 57 { 58 return new static( 59 cid: $data['cid'], 60 playlist: $data['playlist'], 61 thumbnail: $data['thumbnail'] ?? null, 62 alt: $data['alt'] ?? null, 63 aspectRatio: isset($data['aspectRatio']) ? AspectRatio::fromArray($data['aspectRatio']) : null 64 ); 65 } 66 67}