Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 86 lines 2.8 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\Tools\Ozone\Moderation\Defs; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7use SocialDept\AtpSchema\Generated\Com\Atproto\Admin\Defs\ThreatSignature; 8use SocialDept\AtpSchema\Generated\Com\Atproto\Server\Defs\InviteCode; 9 10/** 11 * GENERATED CODE - DO NOT EDIT 12 * 13 * Lexicon: tools.ozone.moderation.defs.repoView 14 * Type: object 15 * 16 * @property string $did 17 * @property string $handle 18 * @property string|null $email 19 * @property array $relatedRecords 20 * @property Carbon $indexedAt 21 * @property mixed $moderation 22 * @property InviteCode|null $invitedBy 23 * @property bool|null $invitesDisabled 24 * @property string|null $inviteNote 25 * @property Carbon|null $deactivatedAt 26 * @property array<ThreatSignature>|null $threatSignatures 27 * 28 * Constraints: 29 * - Required: did, handle, relatedRecords, indexedAt, moderation 30 * - did: Format: did 31 * - handle: Format: handle 32 * - indexedAt: Format: datetime 33 * - deactivatedAt: Format: datetime 34 */ 35class RepoView extends Data 36{ 37 public function __construct( 38 public readonly string $did, 39 public readonly string $handle, 40 public readonly array $relatedRecords, 41 public readonly Carbon $indexedAt, 42 public readonly mixed $moderation, 43 public readonly ?string $email = null, 44 public readonly ?InviteCode $invitedBy = null, 45 public readonly ?bool $invitesDisabled = null, 46 public readonly ?string $inviteNote = null, 47 public readonly ?Carbon $deactivatedAt = null, 48 public readonly ?array $threatSignatures = null 49 ) { 50 } 51 52 /** 53 * Get the lexicon NSID for this data type. 54 * 55 * @return string 56 */ 57 public static function getLexicon(): string 58 { 59 return 'tools.ozone.moderation.defs.repoView'; 60 } 61 62 63 /** 64 * Create an instance from an array. 65 * 66 * @param array $data The data array 67 * @return static 68 */ 69 public static function fromArray(array $data): static 70 { 71 return new static( 72 did: $data['did'], 73 handle: $data['handle'], 74 relatedRecords: $data['relatedRecords'], 75 indexedAt: Carbon::parse($data['indexedAt']), 76 moderation: $data['moderation'], 77 email: $data['email'] ?? null, 78 invitedBy: isset($data['invitedBy']) ? InviteCode::fromArray($data['invitedBy']) : null, 79 invitesDisabled: $data['invitesDisabled'] ?? null, 80 inviteNote: $data['inviteNote'] ?? null, 81 deactivatedAt: isset($data['deactivatedAt']) ? Carbon::parse($data['deactivatedAt']) : null, 82 threatSignatures: isset($data['threatSignatures']) ? array_map(fn ($item) => ThreatSignature::fromArray($item), $data['threatSignatures']) : [] 83 ); 84 } 85 86}