Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 68 lines 2.3 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\Tools\Ozone\Moderation\Defs; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7 8/** 9 * GENERATED CODE - DO NOT EDIT 10 * 11 * Strike information for an account 12 * 13 * Lexicon: tools.ozone.moderation.defs.accountStrike 14 * Type: object 15 * 16 * @property int|null $activeStrikeCount Current number of active strikes (excluding expired strikes) 17 * @property int|null $totalStrikeCount Total number of strikes ever received (including expired strikes) 18 * @property Carbon|null $firstStrikeAt Timestamp of the first strike received 19 * @property Carbon|null $lastStrikeAt Timestamp of the most recent strike received 20 * 21 * Constraints: 22 * - firstStrikeAt: Format: datetime 23 * - lastStrikeAt: Format: datetime 24 */ 25class AccountStrike extends Data 26{ 27 /** 28 * @param int|null $activeStrikeCount Current number of active strikes (excluding expired strikes) 29 * @param int|null $totalStrikeCount Total number of strikes ever received (including expired strikes) 30 * @param Carbon|null $firstStrikeAt Timestamp of the first strike received 31 * @param Carbon|null $lastStrikeAt Timestamp of the most recent strike received 32 */ 33 public function __construct( 34 public readonly ?int $activeStrikeCount = null, 35 public readonly ?int $totalStrikeCount = null, 36 public readonly ?Carbon $firstStrikeAt = null, 37 public readonly ?Carbon $lastStrikeAt = null 38 ) { 39 } 40 41 /** 42 * Get the lexicon NSID for this data type. 43 * 44 * @return string 45 */ 46 public static function getLexicon(): string 47 { 48 return 'tools.ozone.moderation.defs.accountStrike'; 49 } 50 51 52 /** 53 * Create an instance from an array. 54 * 55 * @param array $data The data array 56 * @return static 57 */ 58 public static function fromArray(array $data): static 59 { 60 return new static( 61 activeStrikeCount: $data['activeStrikeCount'] ?? null, 62 totalStrikeCount: $data['totalStrikeCount'] ?? null, 63 firstStrikeAt: isset($data['firstStrikeAt']) ? Carbon::parse($data['firstStrikeAt']) : null, 64 lastStrikeAt: isset($data['lastStrikeAt']) ? Carbon::parse($data['lastStrikeAt']) : null 65 ); 66 } 67 68}