Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 127 lines 4.6 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\App\Bsky\Graph\Defs\StarterPackViewBasic; 8use SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs\Label; 9use SocialDept\AtpSchema\Generated\Com\Atproto\Repo\StrongRef; 10 11/** 12 * GENERATED CODE - DO NOT EDIT 13 * 14 * Lexicon: app.bsky.actor.defs.profileViewDetailed 15 * Type: object 16 * 17 * @property string $did 18 * @property string $handle 19 * @property string|null $displayName 20 * @property string|null $description 21 * @property string|null $pronouns 22 * @property string|null $website 23 * @property string|null $avatar 24 * @property string|null $banner 25 * @property int|null $followersCount 26 * @property int|null $followsCount 27 * @property int|null $postsCount 28 * @property mixed $associated 29 * @property StarterPackViewBasic|null $joinedViaStarterPack 30 * @property Carbon|null $indexedAt 31 * @property Carbon|null $createdAt 32 * @property mixed $viewer 33 * @property array<Label>|null $labels 34 * @property StrongRef|null $pinnedPost 35 * @property mixed $verification 36 * @property mixed $status 37 * @property mixed $debug Debug information for internal development 38 * 39 * Constraints: 40 * - Required: did, handle 41 * - did: Format: did 42 * - handle: Format: handle 43 * - displayName: Max length: 640 44 * - displayName: Max graphemes: 64 45 * - description: Max length: 2560 46 * - description: Max graphemes: 256 47 * - website: Format: uri 48 * - avatar: Format: uri 49 * - banner: Format: uri 50 * - indexedAt: Format: datetime 51 * - createdAt: Format: datetime 52 */ 53class ProfileViewDetailed extends Data 54{ 55 /** 56 * @param mixed $debug Debug information for internal development 57 */ 58 public function __construct( 59 public readonly string $did, 60 public readonly string $handle, 61 public readonly ?string $displayName = null, 62 public readonly ?string $description = null, 63 public readonly ?string $pronouns = null, 64 public readonly ?string $website = null, 65 public readonly ?string $avatar = null, 66 public readonly ?string $banner = null, 67 public readonly ?int $followersCount = null, 68 public readonly ?int $followsCount = null, 69 public readonly ?int $postsCount = null, 70 public readonly mixed $associated = null, 71 public readonly ?StarterPackViewBasic $joinedViaStarterPack = null, 72 public readonly ?Carbon $indexedAt = null, 73 public readonly ?Carbon $createdAt = null, 74 public readonly mixed $viewer = null, 75 public readonly ?array $labels = null, 76 public readonly ?StrongRef $pinnedPost = null, 77 public readonly mixed $verification = null, 78 public readonly mixed $status = null, 79 public readonly mixed $debug = null 80 ) { 81 } 82 83 /** 84 * Get the lexicon NSID for this data type. 85 * 86 * @return string 87 */ 88 public static function getLexicon(): string 89 { 90 return 'app.bsky.actor.defs.profileViewDetailed'; 91 } 92 93 94 /** 95 * Create an instance from an array. 96 * 97 * @param array $data The data array 98 * @return static 99 */ 100 public static function fromArray(array $data): static 101 { 102 return new static( 103 did: $data['did'], 104 handle: $data['handle'], 105 displayName: $data['displayName'] ?? null, 106 description: $data['description'] ?? null, 107 pronouns: $data['pronouns'] ?? null, 108 website: $data['website'] ?? null, 109 avatar: $data['avatar'] ?? null, 110 banner: $data['banner'] ?? null, 111 followersCount: $data['followersCount'] ?? null, 112 followsCount: $data['followsCount'] ?? null, 113 postsCount: $data['postsCount'] ?? null, 114 associated: $data['associated'] ?? null, 115 joinedViaStarterPack: isset($data['joinedViaStarterPack']) ? StarterPackViewBasic::fromArray($data['joinedViaStarterPack']) : null, 116 indexedAt: isset($data['indexedAt']) ? Carbon::parse($data['indexedAt']) : null, 117 createdAt: isset($data['createdAt']) ? Carbon::parse($data['createdAt']) : null, 118 viewer: $data['viewer'] ?? null, 119 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [], 120 pinnedPost: isset($data['pinnedPost']) ? StrongRef::fromArray($data['pinnedPost']) : null, 121 verification: $data['verification'] ?? null, 122 status: $data['status'] ?? null, 123 debug: $data['debug'] ?? null 124 ); 125 } 126 127}