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\Com\Atproto\Label\SubscribeLabels; 4 5use SocialDept\AtpSchema\Data\Data; 6use SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs\Label; 7 8/** 9 * GENERATED CODE - DO NOT EDIT 10 * 11 * Lexicon: com.atproto.label.subscribeLabels.labels 12 * Type: object 13 * 14 * @property int $seq 15 * @property array<Label> $labels 16 * 17 * Constraints: 18 * - Required: seq, labels 19 */ 20class Labels extends Data 21{ 22 public function __construct( 23 public readonly int $seq, 24 public readonly array $labels 25 ) { 26 } 27 28 /** 29 * Get the lexicon NSID for this data type. 30 * 31 * @return string 32 */ 33 public static function getLexicon(): string 34 { 35 return 'com.atproto.label.subscribeLabels.labels'; 36 } 37 38 39 /** 40 * Create an instance from an array. 41 * 42 * @param array $data The data array 43 * @return static 44 */ 45 public static function fromArray(array $data): static 46 { 47 return new static( 48 seq: $data['seq'], 49 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [] 50 ); 51 } 52 53}