Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 53 lines 1.2 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\App\Bsky\Graph; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7 8/** 9 * GENERATED CODE - DO NOT EDIT 10 * 11 * Lexicon: app.bsky.graph.listitem 12 * Type: record 13 */ 14class Listitem extends Data 15{ 16 /** 17 * @param string $subject The account which is included on the list. 18 * @param string $list Reference (AT-URI) to the list record (app.bsky.graph.list). 19 */ 20 public function __construct( 21 public readonly string $subject, 22 public readonly string $list, 23 public readonly Carbon $createdAt 24 ) { 25 } 26 27 /** 28 * Get the lexicon NSID for this data type. 29 * 30 * @return string 31 */ 32 public static function getLexicon(): string 33 { 34 return 'app.bsky.graph.listitem'; 35 } 36 37 38 /** 39 * Create an instance from an array. 40 * 41 * @param array $data The data array 42 * @return static 43 */ 44 public static function fromArray(array $data): static 45 { 46 return new static( 47 subject: $data['subject'], 48 list: $data['list'], 49 createdAt: Carbon::parse($data['createdAt']) 50 ); 51 } 52 53}