Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\App\Bsky\Embed\Images;
4
5use SocialDept\AtpSchema\Data\BlobReference;
6use SocialDept\AtpSchema\Data\Data;
7use SocialDept\AtpSchema\Generated\App\Bsky\Embed\Defs\AspectRatio;
8
9/**
10 * GENERATED CODE - DO NOT EDIT
11 *
12 * Lexicon: app.bsky.embed.images.image
13 * Type: object
14 *
15 * @property BlobReference $image
16 * @property string $alt Alt text description of the image, for accessibility.
17 * @property AspectRatio|null $aspectRatio
18 *
19 * Constraints:
20 * - Required: image, alt
21 */
22class Image extends Data
23{
24 /**
25 * @param string $alt Alt text description of the image, for accessibility.
26 */
27 public function __construct(
28 public readonly BlobReference $image,
29 public readonly string $alt,
30 public readonly ?AspectRatio $aspectRatio = null
31 ) {
32 }
33
34 /**
35 * Get the lexicon NSID for this data type.
36 *
37 * @return string
38 */
39 public static function getLexicon(): string
40 {
41 return 'app.bsky.embed.images.image';
42 }
43
44
45 /**
46 * Create an instance from an array.
47 *
48 * @param array $data The data array
49 * @return static
50 */
51 public static function fromArray(array $data): static
52 {
53 return new static(
54 image: $data['image'],
55 alt: $data['alt'],
56 aspectRatio: isset($data['aspectRatio']) ? AspectRatio::fromArray($data['aspectRatio']) : null
57 );
58 }
59
60}