|
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
|
|
|
* The Actor of a {@link Statement}. |
|
16
|
|
|
* |
|
17
|
|
|
* @author Christian Flothmann <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class Actor |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Name of the {@link Agent} or {@link Group} |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
private $name; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* A mailto IRI |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
private $mbox; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* The SHA1 hash of a mailto IRI |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $mboxSha1Sum; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* An openID uniquely identifying an Agent |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
private $openId; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* A user account on an existing system |
|
47
|
|
|
* @var Account |
|
48
|
|
|
*/ |
|
49
|
|
|
private $account; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param string $mbox |
|
53
|
|
|
* @param string $mboxSha1Sum |
|
54
|
|
|
* @param string $openId |
|
55
|
|
|
* @param Account $account |
|
56
|
|
|
* @param string $name |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __construct($mbox = null, $mboxSha1Sum = null, $openId = null, Account $account = null, $name = null) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->name = $name; |
|
61
|
|
|
$this->mbox = $mbox; |
|
62
|
|
|
$this->mboxSha1Sum = $mboxSha1Sum; |
|
63
|
|
|
$this->openId = $openId; |
|
64
|
|
|
$this->account = $account; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Returns the Actor's inverse functional identifier. |
|
69
|
|
|
* |
|
70
|
|
|
* @return string The inverse functional identifier |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getInverseFunctionalIdentifier() |
|
73
|
|
|
{ |
|
74
|
|
|
if (null !== $this->mbox) { |
|
75
|
|
|
return $this->mbox; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
if (null !== $this->mboxSha1Sum) { |
|
79
|
|
|
return $this->mboxSha1Sum; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
if (null !== $this->openId) { |
|
83
|
|
|
return $this->openId; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
if (null !== $this->account) { |
|
87
|
|
|
return $this->account; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
return null; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Returns the name of the {@link Agent} or {@link Group}. |
|
95
|
|
|
* |
|
96
|
|
|
* @return string The name |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getName() |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->name; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Returns the mailto IRI. |
|
105
|
|
|
* |
|
106
|
|
|
* @return string The mailto IRI |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getMbox() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->mbox; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Returns the SHA1 hash of a mailto IRI. |
|
115
|
|
|
* |
|
116
|
|
|
* @return string The SHA1 hash of a mailto IRI |
|
117
|
|
|
*/ |
|
118
|
|
|
public function getMboxSha1Sum() |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->mboxSha1Sum; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Returns the openID. |
|
125
|
|
|
* |
|
126
|
|
|
* @return string The openID |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getOpenId() |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->openId; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Returns the user account of an existing system. |
|
135
|
|
|
* |
|
136
|
|
|
* @return Account The user account of an existing system |
|
137
|
|
|
*/ |
|
138
|
|
|
public function getAccount() |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->account; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Checks if another actor is equal. |
|
145
|
|
|
* |
|
146
|
|
|
* Two actors are equal if and only if all of their properties are equal. |
|
147
|
|
|
* |
|
148
|
|
|
* @param Actor $actor The actor to compare with |
|
149
|
|
|
* |
|
150
|
|
|
* @return bool True if the actors are equal, false otherwise |
|
151
|
|
|
*/ |
|
152
|
|
|
public function equals(Actor $actor) |
|
153
|
|
|
{ |
|
154
|
|
|
if ($this->name !== $actor->name) { |
|
155
|
|
|
return false; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
if ($this->mbox !== $actor->mbox) { |
|
159
|
|
|
return false; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
if ($this->mboxSha1Sum !== $actor->mboxSha1Sum) { |
|
163
|
|
|
return false; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
if ($this->openId !== $actor->openId) { |
|
167
|
|
|
return false; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
if (null === $this->account && null !== $actor->account) { |
|
171
|
|
|
return false; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
if (null !== $this->account && null === $actor->account) { |
|
175
|
|
|
return false; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
if (null !== $this->account && !$this->account->equals($actor->account)) { |
|
179
|
|
|
return false; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
return true; |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
|