Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\Com\Atproto\Sync\SubscribeRepos;
4
5use Carbon\Carbon;
6use SocialDept\AtpSchema\Data\Data;
7
8/**
9 * GENERATED CODE - DO NOT EDIT
10 *
11 * Represents a change to an account's identity. Could be an updated handle,
12 * signing key, or pds hosting endpoint. Serves as a prod to all downstream
13 * services to refresh their identity cache.
14 *
15 * Lexicon: com.atproto.sync.subscribeRepos.identity
16 * Type: object
17 *
18 * @property int $seq
19 * @property string $did
20 * @property Carbon $time
21 * @property string|null $handle The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.
22 *
23 * Constraints:
24 * - Required: seq, did, time
25 * - did: Format: did
26 * - time: Format: datetime
27 * - handle: Format: handle
28 */
29class Identity extends Data
30{
31 /**
32 * @param string|null $handle The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.
33 */
34 public function __construct(
35 public readonly int $seq,
36 public readonly string $did,
37 public readonly Carbon $time,
38 public readonly ?string $handle = null
39 ) {
40 }
41
42 /**
43 * Get the lexicon NSID for this data type.
44 *
45 * @return string
46 */
47 public static function getLexicon(): string
48 {
49 return 'com.atproto.sync.subscribeRepos.identity';
50 }
51
52
53 /**
54 * Create an instance from an array.
55 *
56 * @param array $data The data array
57 * @return static
58 */
59 public static function fromArray(array $data): static
60 {
61 return new static(
62 seq: $data['seq'],
63 did: $data['did'],
64 time: Carbon::parse($data['time']),
65 handle: $data['handle'] ?? null
66 );
67 }
68
69}