Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs;
4
5use Carbon\Carbon;
6use SocialDept\AtpSchema\Data\Data;
7
8/**
9 * GENERATED CODE - DO NOT EDIT
10 *
11 * A new user experiences (NUX) storage object
12 *
13 * Lexicon: app.bsky.actor.defs.nux
14 * Type: object
15 *
16 * @property string $id
17 * @property bool $completed
18 * @property string|null $data Arbitrary data for the NUX. The structure is defined by the NUX itself. Limited to 300 characters.
19 * @property Carbon|null $expiresAt The date and time at which the NUX will expire and should be considered completed.
20 *
21 * Constraints:
22 * - Required: id, completed
23 * - id: Max length: 100
24 * - data: Max length: 3000
25 * - data: Max graphemes: 300
26 * - expiresAt: Format: datetime
27 */
28class Nux extends Data
29{
30 /**
31 * @param string|null $data Arbitrary data for the NUX. The structure is defined by the NUX itself. Limited to 300 characters.
32 * @param Carbon|null $expiresAt The date and time at which the NUX will expire and should be considered completed.
33 */
34 public function __construct(
35 public readonly string $id,
36 public readonly bool $completed,
37 public readonly ?string $data = null,
38 public readonly ?Carbon $expiresAt = 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 'app.bsky.actor.defs.nux';
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 id: $data['id'],
63 completed: $data['completed'],
64 data: $data['data'] ?? null,
65 expiresAt: isset($data['expiresAt']) ? Carbon::parse($data['expiresAt']) : null
66 );
67 }
68
69}