-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDevice.php
More file actions
64 lines (52 loc) · 1.33 KB
/
Device.php
File metadata and controls
64 lines (52 loc) · 1.33 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\TwoFactorWebauthn\Model;
use OCA\TwoFactorWebauthn\Db\PublicKeyCredentialEntity;
final class Device implements \JsonSerializable {
public function __construct(
private readonly int $entityId,
private readonly string $id,
private readonly string $name,
private readonly ?int $createdAt,
private readonly bool $active,
) {
}
public static function fromPublicKeyCredentialEntity(PublicKeyCredentialEntity $entity): self {
return new self(
$entity->getId(),
$entity->getPublicKeyCredentialId(),
$entity->getName(),
$entity->getCreatedAt(),
$entity->isActive() === true,
);
}
public function getEntityId(): int {
return $this->entityId;
}
public function getId(): string {
return $this->id;
}
public function getName(): string {
return $this->name;
}
public function getCreatedAt(): ?int {
return $this->createdAt;
}
public function isActive(): bool {
return $this->active;
}
#[\ReturnTypeWillChange]
public function jsonSerialize() {
return [
'entityId' => $this->getEntityId(),
'id' => $this->getId(),
'name' => $this->getName(),
'createdAt' => $this->getCreatedAt(),
'active' => $this->isActive(),
];
}
}