Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\Com\Atproto\Repo\ApplyWrites;
4
5use SocialDept\AtpSchema\Data\Data;
6
7/**
8 * GENERATED CODE - DO NOT EDIT
9 *
10 * Operation which creates a new record.
11 *
12 * Lexicon: com.atproto.repo.applyWrites.create
13 * Type: object
14 *
15 * @property string $collection
16 * @property string|null $rkey NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility.
17 * @property mixed $value
18 *
19 * Constraints:
20 * - Required: collection, value
21 * - collection: Format: nsid
22 * - rkey: Max length: 512
23 * - rkey: Format: record-key
24 */
25class Create extends Data
26{
27 /**
28 * @param string|null $rkey NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility.
29 */
30 public function __construct(
31 public readonly string $collection,
32 public readonly mixed $value,
33 public readonly ?string $rkey = 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.repo.applyWrites.create';
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 collection: $data['collection'],
58 value: $data['value'],
59 rkey: $data['rkey'] ?? null
60 );
61 }
62
63}