36 lines
885 B
PHP
36 lines
885 B
PHP
<?php
|
|
namespace Hanyuu\Users\Db;
|
|
|
|
use Index\DateTime;
|
|
use Index\Data\IDbResult;
|
|
use Hanyuu\OTP\TOTPGenerator;
|
|
use Hanyuu\Users\IUserTOTPInfo;
|
|
|
|
class DbUserTOTPInfo implements IUserTOTPInfo {
|
|
private string $userId;
|
|
private string $secretKey;
|
|
private DateTime $changed;
|
|
|
|
public function __construct(IDbResult $result) {
|
|
$this->userId = $result->getString(0);
|
|
$this->secretKey = $result->getString(1);
|
|
$this->changed = DateTime::fromUnixTimeSeconds($result->getInteger(2));
|
|
}
|
|
|
|
public function getUserId(): string {
|
|
return $this->userId;
|
|
}
|
|
|
|
public function getSecretKey(): string {
|
|
return $this->secretKey;
|
|
}
|
|
|
|
public function getChangedTime(): DateTime {
|
|
return $this->changed;
|
|
}
|
|
|
|
public function createGenerator(): TOTPGenerator {
|
|
return new TOTPGenerator($this->secretKey);
|
|
}
|
|
}
|