Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 64 lines 1.8 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\Com\Atproto\Sync\SubscribeRepos; 4 5use SocialDept\AtpSchema\Data\Data; 6 7/** 8 * GENERATED CODE - DO NOT EDIT 9 * 10 * A repo operation, ie a mutation of a single record. 11 * 12 * Lexicon: com.atproto.sync.subscribeRepos.repoOp 13 * Type: object 14 * 15 * @property string $action 16 * @property string $path 17 * @property string $cid For creates and updates, the new record CID. For deletions, null. 18 * @property string|null $prev For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined. 19 * 20 * Constraints: 21 * - Required: action, path, cid 22 */ 23class RepoOp extends Data 24{ 25 /** 26 * @param string $cid For creates and updates, the new record CID. For deletions, null. 27 * @param string|null $prev For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined. 28 */ 29 public function __construct( 30 public readonly string $action, 31 public readonly string $path, 32 public readonly string $cid, 33 public readonly ?string $prev = null 34 ) { 35 } 36 37 /** 38 * Get the lexicon NSID for this data type. 39 * 40 * @return string 41 */ 42 public static function getLexicon(): string 43 { 44 return 'com.atproto.sync.subscribeRepos.repoOp'; 45 } 46 47 48 /** 49 * Create an instance from an array. 50 * 51 * @param array $data The data array 52 * @return static 53 */ 54 public static function fromArray(array $data): static 55 { 56 return new static( 57 action: $data['action'], 58 path: $data['path'], 59 cid: $data['cid'], 60 prev: $data['prev'] ?? null 61 ); 62 } 63 64}