Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 75 lines 2.0 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\Tools\Ozone\Moderation\Defs; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7use SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs\Label; 8 9/** 10 * GENERATED CODE - DO NOT EDIT 11 * 12 * Lexicon: tools.ozone.moderation.defs.recordViewDetail 13 * Type: object 14 * 15 * @property string $uri 16 * @property string $cid 17 * @property mixed $value 18 * @property array $blobs 19 * @property array<Label>|null $labels 20 * @property Carbon $indexedAt 21 * @property mixed $moderation 22 * @property mixed $repo 23 * 24 * Constraints: 25 * - Required: uri, cid, value, blobs, indexedAt, moderation, repo 26 * - uri: Format: at-uri 27 * - cid: Format: cid 28 * - indexedAt: Format: datetime 29 */ 30class RecordViewDetail extends Data 31{ 32 public function __construct( 33 public readonly string $uri, 34 public readonly string $cid, 35 public readonly mixed $value, 36 public readonly array $blobs, 37 public readonly Carbon $indexedAt, 38 public readonly mixed $moderation, 39 public readonly mixed $repo, 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 'tools.ozone.moderation.defs.recordViewDetail'; 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 value: $data['value'], 67 blobs: $data['blobs'] ?? [], 68 indexedAt: Carbon::parse($data['indexedAt']), 69 moderation: $data['moderation'], 70 repo: $data['repo'], 71 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [] 72 ); 73 } 74 75}