Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\App\Bsky\Labeler\Defs;
4
5use Carbon\Carbon;
6use SocialDept\AtpSchema\Data\Data;
7use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileView;
8use SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs\Label;
9use SocialDept\AtpSchema\Generated\Com\Atproto\Moderation\Defs\ReasonType;
10use SocialDept\AtpSchema\Generated\Com\Atproto\Moderation\Defs\SubjectType;
11
12/**
13 * GENERATED CODE - DO NOT EDIT
14 *
15 * Lexicon: app.bsky.labeler.defs.labelerViewDetailed
16 * Type: object
17 *
18 * @property string $uri
19 * @property string $cid
20 * @property ProfileView $creator
21 * @property LabelerPolicies $policies
22 * @property int|null $likeCount
23 * @property mixed $viewer
24 * @property Carbon $indexedAt
25 * @property array<Label>|null $labels
26 * @property array<ReasonType>|null $reasonTypes The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.
27 * @property array<SubjectType>|null $subjectTypes The set of subject types (account, record, etc) this service accepts reports on.
28 * @property array<string>|null $subjectCollections Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.
29 *
30 * Constraints:
31 * - Required: uri, cid, creator, policies, indexedAt
32 * - uri: Format: at-uri
33 * - cid: Format: cid
34 * - likeCount: Minimum: 0
35 * - indexedAt: Format: datetime
36 */
37class LabelerViewDetailed extends Data
38{
39 /**
40 * @param array<ReasonType>|null $reasonTypes The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.
41 * @param array<SubjectType>|null $subjectTypes The set of subject types (account, record, etc) this service accepts reports on.
42 * @param array<string>|null $subjectCollections Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.
43 */
44 public function __construct(
45 public readonly string $uri,
46 public readonly string $cid,
47 public readonly ProfileView $creator,
48 public readonly LabelerPolicies $policies,
49 public readonly Carbon $indexedAt,
50 public readonly ?int $likeCount = null,
51 public readonly mixed $viewer = null,
52 public readonly ?array $labels = null,
53 public readonly ?array $reasonTypes = null,
54 public readonly ?array $subjectTypes = null,
55 public readonly ?array $subjectCollections = null
56 ) {
57 }
58
59 /**
60 * Get the lexicon NSID for this data type.
61 *
62 * @return string
63 */
64 public static function getLexicon(): string
65 {
66 return 'app.bsky.labeler.defs.labelerViewDetailed';
67 }
68
69
70 /**
71 * Create an instance from an array.
72 *
73 * @param array $data The data array
74 * @return static
75 */
76 public static function fromArray(array $data): static
77 {
78 return new static(
79 uri: $data['uri'],
80 cid: $data['cid'],
81 creator: ProfileView::fromArray($data['creator']),
82 policies: LabelerPolicies::fromArray($data['policies']),
83 indexedAt: Carbon::parse($data['indexedAt']),
84 likeCount: $data['likeCount'] ?? null,
85 viewer: $data['viewer'] ?? null,
86 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [],
87 reasonTypes: isset($data['reasonTypes']) ? array_map(fn ($item) => ReasonType::fromArray($item), $data['reasonTypes']) : [],
88 subjectTypes: isset($data['subjectTypes']) ? array_map(fn ($item) => SubjectType::fromArray($item), $data['subjectTypes']) : [],
89 subjectCollections: $data['subjectCollections'] ?? null
90 );
91 }
92
93}