diff options
Diffstat (limited to 'matrix-specification/Responses/LoginFlow.php')
-rw-r--r-- | matrix-specification/Responses/LoginFlow.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/matrix-specification/Responses/LoginFlow.php b/matrix-specification/Responses/LoginFlow.php new file mode 100644 index 0000000..6ddb703 --- /dev/null +++ b/matrix-specification/Responses/LoginFlow.php @@ -0,0 +1,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; + } +} |