Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 71 lines 1.9 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\Support\UnionHelper; 8 9/** 10 * GENERATED CODE - DO NOT EDIT 11 * 12 * Lexicon: tools.ozone.moderation.defs.modEventViewDetail 13 * Type: object 14 * 15 * @property int $id 16 * @property mixed $event 17 * @property mixed $subject 18 * @property array $subjectBlobs 19 * @property string $createdBy 20 * @property Carbon $createdAt 21 * @property mixed $modTool 22 * 23 * Constraints: 24 * - Required: id, event, subject, subjectBlobs, createdBy, createdAt 25 * - createdBy: Format: did 26 * - createdAt: Format: datetime 27 */ 28class ModEventViewDetail extends Data 29{ 30 public function __construct( 31 public readonly int $id, 32 public readonly mixed $event, 33 public readonly mixed $subject, 34 public readonly array $subjectBlobs, 35 public readonly string $createdBy, 36 public readonly Carbon $createdAt, 37 public readonly mixed $modTool = null 38 ) { 39 } 40 41 /** 42 * Get the lexicon NSID for this data type. 43 * 44 * @return string 45 */ 46 public static function getLexicon(): string 47 { 48 return 'tools.ozone.moderation.defs.modEventViewDetail'; 49 } 50 51 52 /** 53 * Create an instance from an array. 54 * 55 * @param array $data The data array 56 * @return static 57 */ 58 public static function fromArray(array $data): static 59 { 60 return new static( 61 id: $data['id'], 62 event: UnionHelper::validateOpenUnion($data['event']), 63 subject: UnionHelper::validateOpenUnion($data['subject']), 64 subjectBlobs: $data['subjectBlobs'] ?? [], 65 createdBy: $data['createdBy'], 66 createdAt: Carbon::parse($data['createdAt']), 67 modTool: $data['modTool'] ?? null 68 ); 69 } 70 71}