1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the xAPI package. |
5
|
|
|
* |
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Model; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Combined informations from multiple {@link Agent agents}. |
16
|
|
|
* |
17
|
|
|
* @author Jérôme Parmentier <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
final class Person |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string[] List of names of Agents |
23
|
|
|
*/ |
24
|
|
|
private $names = array(); |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var IRI[] List of mailto IRIs of Agents |
28
|
|
|
*/ |
29
|
|
|
private $mboxes = array(); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string[] List of the SHA1 hashes of mailto IRIs of Agents |
33
|
|
|
*/ |
34
|
|
|
private $mboxSha1Sums = array(); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string[] List of openids that uniquely identify the Agents |
38
|
|
|
*/ |
39
|
|
|
private $openIds = array(); |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var Account[] List of accounts of Agents |
43
|
|
|
*/ |
44
|
|
|
private $accounts = array(); |
45
|
|
|
|
46
|
|
|
private function __construct() |
47
|
|
|
{ |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param Agent[] $agents |
52
|
|
|
*/ |
53
|
|
|
public static function createFromAgents(array $agents): self |
54
|
|
|
{ |
55
|
|
|
$person = new self(); |
56
|
|
|
|
57
|
|
|
foreach ($agents as $agent) { |
58
|
|
|
$iri = $agent->getInverseFunctionalIdentifier(); |
59
|
|
|
|
60
|
|
|
if (null !== $mbox = $iri->getMbox()) { |
61
|
|
|
$person->mboxes[] = $mbox; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
if (null !== $mboxSha1Sum = $iri->getMboxSha1Sum()) { |
65
|
|
|
$person->mboxSha1Sums[] = $mboxSha1Sum; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if (null !== $openId = $iri->getOpenId()) { |
69
|
|
|
$person->openIds[] = $openId; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if (null !== $account = $iri->getAccount()) { |
73
|
|
|
$person->accounts[] = $account; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if (null !== $name = $agent->getName()) { |
77
|
|
|
$person->names[] = $name; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $person; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string[] |
86
|
|
|
*/ |
87
|
|
|
public function getNames(): array |
88
|
|
|
{ |
89
|
|
|
return $this->names; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return IRI[] |
94
|
|
|
*/ |
95
|
|
|
public function getMboxes(): array |
96
|
|
|
{ |
97
|
|
|
return $this->mboxes; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string[] |
102
|
|
|
*/ |
103
|
|
|
public function getMboxSha1Sums(): array |
104
|
|
|
{ |
105
|
|
|
return $this->mboxSha1Sums; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string[] |
110
|
|
|
*/ |
111
|
|
|
public function getOpenIds(): array |
112
|
|
|
{ |
113
|
|
|
return $this->openIds; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return Account[] |
118
|
|
|
*/ |
119
|
|
|
public function getAccounts(): array |
120
|
|
|
{ |
121
|
|
|
return $this->accounts; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|