54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
final class Fingerprint extends MySqlTable implements JsonSerializable
|
||
|
{
|
||
|
public const FIELD_ID = 'FingerprintId';
|
||
|
public const FIELD_FINGERPRINT = 'Fingerprint';
|
||
|
public const FIELD_USER = 'UserId';
|
||
|
|
||
|
public function __construct($id = null, DatabaseInterface &$database = null)
|
||
|
{
|
||
|
parent::__construct(self::class, $id, $database);
|
||
|
}
|
||
|
|
||
|
public function getFingerprintId(): ?int
|
||
|
{
|
||
|
if ($this->getPrimaryKey() === null) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return (int)$this->getPrimaryKey();
|
||
|
}
|
||
|
|
||
|
public function getFingerprint(): string
|
||
|
{
|
||
|
return $this->getField(self::FIELD_FINGERPRINT);
|
||
|
}
|
||
|
|
||
|
public function getUserId(): int
|
||
|
{
|
||
|
return $this->getField(self::FIELD_USER);
|
||
|
}
|
||
|
|
||
|
public function setFingerprint(string $fingerprint): void
|
||
|
{
|
||
|
$this->setField(self::FIELD_FINGERPRINT, $fingerprint);
|
||
|
}
|
||
|
|
||
|
public function setUserId(int $userId): void
|
||
|
{
|
||
|
$this->setField(self::FIELD_USER, $userId);
|
||
|
}
|
||
|
|
||
|
public function jsonSerialize(): array
|
||
|
{
|
||
|
return [
|
||
|
'fingerprintId' => $this->getFingerprintId(),
|
||
|
'fingerprint' => $this->getFingerprint(),
|
||
|
'userId' => $this->getUserId()
|
||
|
];
|
||
|
}
|
||
|
}
|