Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\App\Bsky\Actor\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: app.bsky.actor.defs.statusView
13 * Type: object
14 *
15 * @property string $status The status for the account.
16 * @property mixed $record
17 * @property mixed $embed An optional embed associated with the status.
18 * @property Carbon|null $expiresAt The date when this status will expire. The application might choose to no longer return the status after expiration.
19 * @property bool|null $isActive True if the status is not expired, false if it is expired. Only present if expiration was set.
20 *
21 * Constraints:
22 * - Required: status, record
23 * - expiresAt: Format: datetime
24 */
25class StatusView extends Data
26{
27 /**
28 * @param string $status The status for the account.
29 * @param mixed $embed An optional embed associated with the status.
30 * @param Carbon|null $expiresAt The date when this status will expire. The application might choose to no longer return the status after expiration.
31 * @param bool|null $isActive True if the status is not expired, false if it is expired. Only present if expiration was set.
32 */
33 public function __construct(
34 public readonly string $status,
35 public readonly mixed $record,
36 public readonly mixed $embed = null,
37 public readonly ?Carbon $expiresAt = null,
38 public readonly ?bool $isActive = null
39 ) {
40 }
41
42 /**
43 * Get the lexicon NSID for this data type.
44 *
45 * @return string
46 */
47 public static function getLexicon(): string
48 {
49 return 'app.bsky.actor.defs.statusView';
50 }
51
52
53 /**
54 * Create an instance from an array.
55 *
56 * @param array $data The data array
57 * @return static
58 */
59 public static function fromArray(array $data): static
60 {
61 return new static(
62 status: $data['status'],
63 record: $data['record'],
64 embed: isset($data['embed']) ? UnionHelper::validateOpenUnion($data['embed']) : null,
65 expiresAt: isset($data['expiresAt']) ? Carbon::parse($data['expiresAt']) : null,
66 isActive: $data['isActive'] ?? null
67 );
68 }
69
70}