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;
7
8/**
9 * GENERATED CODE - DO NOT EDIT
10 *
11 * A word that the account owner has muted.
12 *
13 * Lexicon: app.bsky.actor.defs.mutedWord
14 * Type: object
15 *
16 * @property string|null $id
17 * @property string $value The muted word itself.
18 * @property array<MutedWordTarget> $targets The intended targets of the muted word.
19 * @property string|null $actorTarget Groups of users to apply the muted word to. If undefined, applies to all users.
20 * @property Carbon|null $expiresAt The date and time at which the muted word will expire and no longer be applied.
21 *
22 * Constraints:
23 * - Required: value, targets
24 * - value: Max length: 10000
25 * - value: Max graphemes: 1000
26 * - expiresAt: Format: datetime
27 */
28class MutedWord extends Data
29{
30 /**
31 * @param string $value The muted word itself.
32 * @param array<MutedWordTarget> $targets The intended targets of the muted word.
33 * @param string|null $actorTarget Groups of users to apply the muted word to. If undefined, applies to all users.
34 * @param Carbon|null $expiresAt The date and time at which the muted word will expire and no longer be applied.
35 */
36 public function __construct(
37 public readonly string $value,
38 public readonly array $targets,
39 public readonly ?string $id = null,
40 public readonly ?string $actorTarget = null,
41 public readonly ?Carbon $expiresAt = null
42 ) {
43 }
44
45 /**
46 * Get the lexicon NSID for this data type.
47 *
48 * @return string
49 */
50 public static function getLexicon(): string
51 {
52 return 'app.bsky.actor.defs.mutedWord';
53 }
54
55
56 /**
57 * Create an instance from an array.
58 *
59 * @param array $data The data array
60 * @return static
61 */
62 public static function fromArray(array $data): static
63 {
64 return new static(
65 value: $data['value'],
66 targets: isset($data['targets']) ? array_map(fn ($item) => MutedWordTarget::fromArray($item), $data['targets']) : [],
67 id: $data['id'] ?? null,
68 actorTarget: $data['actorTarget'] ?? null,
69 expiresAt: isset($data['expiresAt']) ? Carbon::parse($data['expiresAt']) : null
70 );
71 }
72
73}