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 status on a host (eg, PDS or Relay). The
12 * semantics of this event are that the status is at the host which emitted the
13 * event, not necessarily that at the currently active PDS. Eg, a Relay takedown
14 * would emit a takedown with active=false, even if the PDS is still active.
15 *
16 * Lexicon: com.atproto.sync.subscribeRepos.account
17 * Type: object
18 *
19 * @property int $seq
20 * @property string $did
21 * @property Carbon $time
22 * @property bool $active Indicates that the account has a repository which can be fetched from the host that emitted this event.
23 * @property string|null $status If active=false, this optional field indicates a reason for why the account is not active.
24 *
25 * Constraints:
26 * - Required: seq, did, time, active
27 * - did: Format: did
28 * - time: Format: datetime
29 */
30class Account extends Data
31{
32 /**
33 * @param bool $active Indicates that the account has a repository which can be fetched from the host that emitted this event.
34 * @param string|null $status If active=false, this optional field indicates a reason for why the account is not active.
35 */
36 public function __construct(
37 public readonly int $seq,
38 public readonly string $did,
39 public readonly Carbon $time,
40 public readonly bool $active,
41 public readonly ?string $status = null
42 ) {
43 }
44
45 /**
46 * Get the lexicon NSID for this data type.
47 *
48 * @return string
49 */
50 public static function getLexicon(): string
51 {
52 return 'com.atproto.sync.subscribeRepos.account';
53 }
54
55
56 /**
57 * Create an instance from an array.
58 *
59 * @param array $data The data array
60 * @return static
61 */
62 public static function fromArray(array $data): static
63 {
64 return new static(
65 seq: $data['seq'],
66 did: $data['did'],
67 time: Carbon::parse($data['time']),
68 active: $data['active'],
69 status: $data['status'] ?? null
70 );
71 }
72
73}