Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 102 lines 3.2 kB view raw
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.profileView 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 $description 20 * @property string|null $avatar 21 * @property mixed $associated 22 * @property Carbon|null $indexedAt 23 * @property Carbon|null $createdAt 24 * @property mixed $viewer 25 * @property array<Label>|null $labels 26 * @property mixed $verification 27 * @property mixed $status 28 * @property mixed $debug Debug information for internal development 29 * 30 * Constraints: 31 * - Required: did, handle 32 * - did: Format: did 33 * - handle: Format: handle 34 * - displayName: Max length: 640 35 * - displayName: Max graphemes: 64 36 * - description: Max length: 2560 37 * - description: Max graphemes: 256 38 * - avatar: Format: uri 39 * - indexedAt: Format: datetime 40 * - createdAt: Format: datetime 41 */ 42class ProfileView extends Data 43{ 44 /** 45 * @param mixed $debug Debug information for internal development 46 */ 47 public function __construct( 48 public readonly string $did, 49 public readonly string $handle, 50 public readonly ?string $displayName = null, 51 public readonly ?string $pronouns = null, 52 public readonly ?string $description = null, 53 public readonly ?string $avatar = null, 54 public readonly mixed $associated = null, 55 public readonly ?Carbon $indexedAt = null, 56 public readonly ?Carbon $createdAt = null, 57 public readonly mixed $viewer = null, 58 public readonly ?array $labels = null, 59 public readonly mixed $verification = null, 60 public readonly mixed $status = null, 61 public readonly mixed $debug = null 62 ) { 63 } 64 65 /** 66 * Get the lexicon NSID for this data type. 67 * 68 * @return string 69 */ 70 public static function getLexicon(): string 71 { 72 return 'app.bsky.actor.defs.profileView'; 73 } 74 75 76 /** 77 * Create an instance from an array. 78 * 79 * @param array $data The data array 80 * @return static 81 */ 82 public static function fromArray(array $data): static 83 { 84 return new static( 85 did: $data['did'], 86 handle: $data['handle'], 87 displayName: $data['displayName'] ?? null, 88 pronouns: $data['pronouns'] ?? null, 89 description: $data['description'] ?? null, 90 avatar: $data['avatar'] ?? null, 91 associated: $data['associated'] ?? null, 92 indexedAt: isset($data['indexedAt']) ? Carbon::parse($data['indexedAt']) : null, 93 createdAt: isset($data['createdAt']) ? Carbon::parse($data['createdAt']) : null, 94 viewer: $data['viewer'] ?? null, 95 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [], 96 verification: $data['verification'] ?? null, 97 status: $data['status'] ?? null, 98 debug: $data['debug'] ?? null 99 ); 100 } 101 102}