1 | <?php |
||
19 | final class InverseFunctionalIdentifier |
||
20 | { |
||
21 | /** |
||
22 | * @var IRI A mailto IRI |
||
23 | */ |
||
24 | private $mbox; |
||
25 | |||
26 | /** |
||
27 | * @var string The SHA1 hash of a mailto IRI |
||
28 | */ |
||
29 | private $mboxSha1Sum; |
||
30 | |||
31 | /** |
||
32 | * @var string An openID uniquely identifying an Agent |
||
33 | */ |
||
34 | private $openId; |
||
35 | |||
36 | /** |
||
37 | * @var Account A user account on an existing system |
||
38 | */ |
||
39 | private $account; |
||
40 | |||
41 | /** |
||
42 | * Use one of the with*() factory methods to obtain an InverseFunctionalIdentifier |
||
43 | * instance. |
||
44 | */ |
||
45 | 15 | private function __construct() |
|
48 | |||
49 | 10 | public static function withMbox(IRI $mbox) |
|
56 | |||
57 | 6 | public static function withMboxSha1Sum($mboxSha1Sum) |
|
64 | |||
65 | public static function withOpenId($openId) |
||
72 | |||
73 | 3 | public static function withAccount(Account $account) |
|
80 | |||
81 | /** |
||
82 | * Returns the mailto IRI. |
||
83 | * |
||
84 | * @return IRI The mailto IRI |
||
85 | */ |
||
86 | public function getMbox() |
||
90 | |||
91 | /** |
||
92 | * Returns the SHA1 hash of a mailto IRI. |
||
93 | * |
||
94 | * @return string The SHA1 hash of a mailto IRI |
||
95 | */ |
||
96 | public function getMboxSha1Sum() |
||
100 | |||
101 | /** |
||
102 | * Returns the openID. |
||
103 | * |
||
104 | * @return string The openID |
||
105 | */ |
||
106 | public function getOpenId() |
||
110 | |||
111 | /** |
||
112 | * Returns the user account of an existing system. |
||
113 | * |
||
114 | * @return Account The user account of an existing system |
||
115 | */ |
||
116 | public function getAccount() |
||
120 | |||
121 | /** |
||
122 | * Checks if another IRI is equal. |
||
123 | * |
||
124 | * Two inverse functional identifiers are equal if and only if all of their |
||
125 | * properties are equal. |
||
126 | * |
||
127 | * @param InverseFunctionalIdentifier $iri The iri to compare with |
||
128 | * |
||
129 | * @return bool True if the IRIs are equal, false otherwise |
||
130 | */ |
||
131 | 19 | public function equals(InverseFunctionalIdentifier $iri) |
|
132 | { |
||
133 | 19 | if (null !== $this->mbox && null !== $iri->mbox && !$this->mbox->equals($iri->mbox)) { |
|
134 | 2 | return false; |
|
135 | } |
||
136 | |||
137 | 17 | if ($this->mboxSha1Sum !== $iri->mboxSha1Sum) { |
|
138 | 6 | return false; |
|
139 | } |
||
140 | |||
141 | 11 | if ($this->openId !== $iri->openId) { |
|
142 | 2 | return false; |
|
143 | } |
||
144 | |||
145 | 9 | if (null === $this->account && null !== $iri->account) { |
|
146 | return false; |
||
147 | } |
||
148 | |||
149 | 9 | if (null !== $this->account && null === $iri->account) { |
|
150 | return false; |
||
151 | } |
||
152 | |||
153 | 9 | if (null !== $this->account && !$this->account->equals($iri->account)) { |
|
154 | 4 | return false; |
|
155 | } |
||
156 | |||
157 | 5 | return true; |
|
158 | } |
||
159 | |||
160 | public function __toString() |
||
176 | } |
||
177 |