Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\App\Bsky\Graph\Defs;
4
5use SocialDept\AtpSchema\Data\Data;
6
7/**
8 * GENERATED CODE - DO NOT EDIT
9 *
10 * lists the bi-directional graph relationships between one actor (not indicated
11 * in the object), and the target actors (the DID included in the object)
12 *
13 * Lexicon: app.bsky.graph.defs.relationship
14 * Type: object
15 *
16 * @property string $did
17 * @property string|null $following if the actor follows this DID, this is the AT-URI of the follow record
18 * @property string|null $followedBy if the actor is followed by this DID, contains the AT-URI of the follow record
19 *
20 * Constraints:
21 * - Required: did
22 * - did: Format: did
23 * - following: Format: at-uri
24 * - followedBy: Format: at-uri
25 */
26class Relationship extends Data
27{
28 /**
29 * @param string|null $following if the actor follows this DID, this is the AT-URI of the follow record
30 * @param string|null $followedBy if the actor is followed by this DID, contains the AT-URI of the follow record
31 */
32 public function __construct(
33 public readonly string $did,
34 public readonly ?string $following = null,
35 public readonly ?string $followedBy = 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 'app.bsky.graph.defs.relationship';
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 did: $data['did'],
60 following: $data['following'] ?? null,
61 followedBy: $data['followedBy'] ?? null
62 );
63 }
64
65}