Files
server/shared/lib/Mail/Service/ServiceIdentityBasic.php
2025-12-21 10:09:54 -05:00

79 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Mail\Service;
/**
* Mail Service Basic Identity Implementation
*
* Username/password authentication credentials.
*
* @since 2025.05.01
*/
class ServiceIdentityBasic implements IServiceIdentityBasic {
/**
* @param string $username Login username
* @param string $password Login password
*/
public function __construct(
private string $username,
private string $password,
) {}
/**
* Creates from array data
*
* @since 2025.05.01
*
* @param array $data
*
* @return self
*/
public static function fromArray(array $data): self {
return new self(
$data['username'] ?? '',
$data['password'] ?? '',
);
}
/**
* @inheritDoc
*/
public function getType(): string {
return self::TYPE_BASIC;
}
/**
* @inheritDoc
*/
public function getUsername(): string {
return $this->username;
}
/**
* @inheritDoc
*/
public function getPassword(): string {
return $this->password;
}
/**
* @inheritDoc
*/
public function jsonSerialize(): array {
return [
'type' => self::TYPE_BASIC,
'username' => $this->username,
// Password intentionally omitted from serialization for security
];
}
}