Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 60 lines 1.4 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\Com\Atproto\Server\CreateAppPassword; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7 8/** 9 * GENERATED CODE - DO NOT EDIT 10 * 11 * Lexicon: com.atproto.server.createAppPassword.appPassword 12 * Type: object 13 * 14 * @property string $name 15 * @property string $password 16 * @property Carbon $createdAt 17 * @property bool|null $privileged 18 * 19 * Constraints: 20 * - Required: name, password, createdAt 21 * - createdAt: Format: datetime 22 */ 23class AppPassword extends Data 24{ 25 public function __construct( 26 public readonly string $name, 27 public readonly string $password, 28 public readonly Carbon $createdAt, 29 public readonly ?bool $privileged = null 30 ) { 31 } 32 33 /** 34 * Get the lexicon NSID for this data type. 35 * 36 * @return string 37 */ 38 public static function getLexicon(): string 39 { 40 return 'com.atproto.server.createAppPassword.appPassword'; 41 } 42 43 44 /** 45 * Create an instance from an array. 46 * 47 * @param array $data The data array 48 * @return static 49 */ 50 public static function fromArray(array $data): static 51 { 52 return new static( 53 name: $data['name'], 54 password: $data['password'], 55 createdAt: Carbon::parse($data['createdAt']), 56 privileged: $data['privileged'] ?? null 57 ); 58 } 59 60}