Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs;
4
5use Carbon\Carbon;
6use SocialDept\AtpSchema\Data\Data;
7
8/**
9 * GENERATED CODE - DO NOT EDIT
10 *
11 * Metadata tag on an atproto resource (eg, repo or record).
12 *
13 * Lexicon: com.atproto.label.defs.label
14 * Type: object
15 *
16 * @property int|null $ver The AT Protocol version of the label object.
17 * @property string $src DID of the actor who created this label.
18 * @property string $uri AT URI of the record, repository (account), or other resource that this label applies to.
19 * @property string|null $cid Optionally, CID specifying the specific version of 'uri' resource this label applies to.
20 * @property string $val The short string name of the value or type of this label.
21 * @property bool|null $neg If true, this is a negation label, overwriting a previous label.
22 * @property Carbon $cts Timestamp when this label was created.
23 * @property Carbon|null $exp Timestamp at which this label expires (no longer applies).
24 * @property string|null $sig Signature of dag-cbor encoded label.
25 *
26 * Constraints:
27 * - Required: src, uri, val, cts
28 * - src: Format: did
29 * - uri: Format: uri
30 * - cid: Format: cid
31 * - val: Max length: 128
32 * - cts: Format: datetime
33 * - exp: Format: datetime
34 */
35class Label extends Data
36{
37 /**
38 * @param string $src DID of the actor who created this label.
39 * @param string $uri AT URI of the record, repository (account), or other resource that this label applies to.
40 * @param string $val The short string name of the value or type of this label.
41 * @param Carbon $cts Timestamp when this label was created.
42 * @param int|null $ver The AT Protocol version of the label object.
43 * @param string|null $cid Optionally, CID specifying the specific version of 'uri' resource this label applies to.
44 * @param bool|null $neg If true, this is a negation label, overwriting a previous label.
45 * @param Carbon|null $exp Timestamp at which this label expires (no longer applies).
46 * @param string|null $sig Signature of dag-cbor encoded label.
47 */
48 public function __construct(
49 public readonly string $src,
50 public readonly string $uri,
51 public readonly string $val,
52 public readonly Carbon $cts,
53 public readonly ?int $ver = null,
54 public readonly ?string $cid = null,
55 public readonly ?bool $neg = null,
56 public readonly ?Carbon $exp = null,
57 public readonly ?string $sig = null
58 ) {
59 }
60
61 /**
62 * Get the lexicon NSID for this data type.
63 *
64 * @return string
65 */
66 public static function getLexicon(): string
67 {
68 return 'com.atproto.label.defs.label';
69 }
70
71
72 /**
73 * Create an instance from an array.
74 *
75 * @param array $data The data array
76 * @return static
77 */
78 public static function fromArray(array $data): static
79 {
80 return new static(
81 src: $data['src'],
82 uri: $data['uri'],
83 val: $data['val'],
84 cts: Carbon::parse($data['cts']),
85 ver: $data['ver'] ?? null,
86 cid: $data['cid'] ?? null,
87 neg: $data['neg'] ?? null,
88 exp: isset($data['exp']) ? Carbon::parse($data['exp']) : null,
89 sig: $data['sig'] ?? null
90 );
91 }
92
93}