Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\Tools\Ozone\Moderation\Defs;
4
5use SocialDept\AtpSchema\Data\Data;
6use SocialDept\AtpSchema\Generated\Com\Atproto\Moderation\Defs\SubjectType;
7use SocialDept\AtpSchema\Support\UnionHelper;
8
9/**
10 * GENERATED CODE - DO NOT EDIT
11 *
12 * Detailed view of a subject. For record subjects, the author's repo and
13 * profile will be returned.
14 *
15 * Lexicon: tools.ozone.moderation.defs.subjectView
16 * Type: object
17 *
18 * @property SubjectType $type
19 * @property string $subject
20 * @property mixed $status
21 * @property mixed $repo
22 * @property mixed $profile
23 * @property mixed $record
24 *
25 * Constraints:
26 * - Required: type, subject
27 */
28class SubjectView extends Data
29{
30 public function __construct(
31 public readonly SubjectType $type,
32 public readonly string $subject,
33 public readonly mixed $status = null,
34 public readonly mixed $repo = null,
35 public readonly mixed $profile = null,
36 public readonly mixed $record = null
37 ) {
38 }
39
40 /**
41 * Get the lexicon NSID for this data type.
42 *
43 * @return string
44 */
45 public static function getLexicon(): string
46 {
47 return 'tools.ozone.moderation.defs.subjectView';
48 }
49
50
51 /**
52 * Create an instance from an array.
53 *
54 * @param array $data The data array
55 * @return static
56 */
57 public static function fromArray(array $data): static
58 {
59 return new static(
60 type: SubjectType::fromArray($data['type']),
61 subject: $data['subject'],
62 status: $data['status'] ?? null,
63 repo: $data['repo'] ?? null,
64 profile: isset($data['profile']) ? UnionHelper::validateOpenUnion($data['profile']) : null,
65 record: $data['record'] ?? null
66 );
67 }
68
69}