-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
PublicKey.php
57 lines (44 loc) · 1.29 KB
/
PublicKey.php
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
<?php declare(strict_types = 1);
namespace PharIo\Phive;
class PublicKey {
/** @var string */
private $id;
/** @var string */
private $fingerprint;
/** @var array */
private $uids;
/** @var string */
private $public;
/** @var \DateTimeImmutable */
private $created;
/**
* PublicKey constructor.
*/
public function __construct(string $id, string $fingerprint, array $uids, string $public, \DateTimeImmutable $created) {
$this->id = $id;
$this->fingerprint = $fingerprint;
$this->uids = $uids;
$this->public = $public;
$this->created = $created;
}
public function getId(): string {
return $this->id;
}
public function getInfo(): string {
$info = [];
$info[] = "\tFingerprint: " . \implode(' ', \str_split($this->fingerprint, 4));
$info[] = '';
foreach ($this->uids as $uid) {
$info[] = \sprintf("\t%s", $uid);
}
$info[] = '';
$info[] = "\tCreated: " . $this->created->format('Y-m-d');
return \implode("\n", $info);
}
public function getKeyData(): string {
return $this->public;
}
public function getFingerprint(): string {
return $this->fingerprint;
}
}