summaryrefslogtreecommitdiff
path: root/matrix-specification/Responses/LoginFlow.php
blob: 6ddb703250dccbdcc76416f0d2e1d190c8729de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Matrix\Responses;

use Matrix\Enums\LoginType;

class LoginFlow implements \JsonSerializable
{
  public function __construct(
    private LoginType $type,
    private ?bool $getLoginToken = null,
  )
  {}

  public function jsonSerialize(): array
  {
    $loginFlow = [
      "type" => $this->type,
    ];

    $loginFlow += match ($this->type) {
      LoginType::TOKEN => [
        "get_login_token" => $this->getLoginToken,
      ],

      default => [],
    };

    return $loginFlow;
  }
}