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;
7use SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs\Label;
8
9/**
10 * GENERATED CODE - DO NOT EDIT
11 *
12 * Lexicon: app.bsky.actor.defs.profileViewBasic
13 * Type: object
14 *
15 * @property string $did
16 * @property string $handle
17 * @property string|null $displayName
18 * @property string|null $pronouns
19 * @property string|null $avatar
20 * @property mixed $associated
21 * @property mixed $viewer
22 * @property array<Label>|null $labels
23 * @property Carbon|null $createdAt
24 * @property mixed $verification
25 * @property mixed $status
26 * @property mixed $debug Debug information for internal development
27 *
28 * Constraints:
29 * - Required: did, handle
30 * - did: Format: did
31 * - handle: Format: handle
32 * - displayName: Max length: 640
33 * - displayName: Max graphemes: 64
34 * - avatar: Format: uri
35 * - createdAt: Format: datetime
36 */
37class ProfileViewBasic extends Data
38{
39 /**
40 * @param mixed $debug Debug information for internal development
41 */
42 public function __construct(
43 public readonly string $did,
44 public readonly string $handle,
45 public readonly ?string $displayName = null,
46 public readonly ?string $pronouns = null,
47 public readonly ?string $avatar = null,
48 public readonly mixed $associated = null,
49 public readonly mixed $viewer = null,
50 public readonly ?array $labels = null,
51 public readonly ?Carbon $createdAt = null,
52 public readonly mixed $verification = null,
53 public readonly mixed $status = null,
54 public readonly mixed $debug = null
55 ) {
56 }
57
58 /**
59 * Get the lexicon NSID for this data type.
60 *
61 * @return string
62 */
63 public static function getLexicon(): string
64 {
65 return 'app.bsky.actor.defs.profileViewBasic';
66 }
67
68
69 /**
70 * Create an instance from an array.
71 *
72 * @param array $data The data array
73 * @return static
74 */
75 public static function fromArray(array $data): static
76 {
77 return new static(
78 did: $data['did'],
79 handle: $data['handle'],
80 displayName: $data['displayName'] ?? null,
81 pronouns: $data['pronouns'] ?? null,
82 avatar: $data['avatar'] ?? null,
83 associated: $data['associated'] ?? null,
84 viewer: $data['viewer'] ?? null,
85 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [],
86 createdAt: isset($data['createdAt']) ? Carbon::parse($data['createdAt']) : null,
87 verification: $data['verification'] ?? null,
88 status: $data['status'] ?? null,
89 debug: $data['debug'] ?? null
90 );
91 }
92
93}