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