Laravel AT Protocol Client (alpha & unstable)
1<?php
2
3namespace SocialDept\AtpClient\Data\Responses\Atproto\Server;
4
5use Illuminate\Contracts\Support\Arrayable;
6
7/**
8 * @implements Arrayable<string, mixed>
9 */
10class GetSessionResponse implements Arrayable
11{
12 public function __construct(
13 public readonly string $handle,
14 public readonly string $did,
15 public readonly ?string $email = null,
16 public readonly ?bool $emailConfirmed = null,
17 public readonly ?bool $emailAuthFactor = null,
18 public readonly mixed $didDoc = null,
19 public readonly ?bool $active = null,
20 public readonly ?string $status = null,
21 ) {}
22
23 public static function fromArray(array $data): self
24 {
25 return new self(
26 handle: $data['handle'],
27 did: $data['did'],
28 email: $data['email'] ?? null,
29 emailConfirmed: $data['emailConfirmed'] ?? null,
30 emailAuthFactor: $data['emailAuthFactor'] ?? null,
31 didDoc: $data['didDoc'] ?? null,
32 active: $data['active'] ?? null,
33 status: $data['status'] ?? null,
34 );
35 }
36
37 public function toArray(): array
38 {
39 return [
40 'handle' => $this->handle,
41 'did' => $this->did,
42 'email' => $this->email,
43 'emailConfirmed' => $this->emailConfirmed,
44 'emailAuthFactor' => $this->emailAuthFactor,
45 'didDoc' => $this->didDoc,
46 'active' => $this->active,
47 'status' => $this->status,
48 ];
49 }
50}