1 | <?php |
||
29 | class Address { |
||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $cloudId; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $displayName; |
||
39 | |||
40 | /** |
||
41 | * Address constructor. |
||
42 | * |
||
43 | * @param string $cloudId |
||
44 | * @param string $displayName |
||
45 | */ |
||
46 | public function __construct($cloudId, $displayName = '') { |
||
50 | |||
51 | /** |
||
52 | * Get user federated id |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getCloudId() { |
||
61 | |||
62 | /** |
||
63 | * Get user id |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function getUserId() { |
||
73 | |||
74 | /** |
||
75 | * Get user host without protocol, index.php and a trailing slash |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public function getHostName() { |
||
80 | // hostname is the last part |
||
81 | $origin = $this->getCleanOrigin(); |
||
82 | |||
83 | // replace all characters before :// and :// itself |
||
84 | return \preg_replace('|^(.*?://)|', '', $origin); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Get user host with protocol but without trailing slash and index.php |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getOrigin() { |
||
93 | return $this->getCleanOrigin(); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Get user display name, fallback to userId if it is empty |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getDisplayName() { |
||
104 | |||
105 | /** |
||
106 | * Checks if the user and host is the same with another address |
||
107 | * |
||
108 | * @param Address $address |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function equalTo(Address $address) { |
||
118 | |||
119 | /** |
||
120 | * Some kind of ancient magic that was copypasted here and there |
||
121 | * |
||
122 | * @return mixed |
||
123 | */ |
||
124 | public function toLocalUid() { |
||
127 | |||
128 | /** |
||
129 | * Cut index.php and trailing slash from remote URL |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | protected function getCleanOrigin() { |
||
148 | |||
149 | /** |
||
150 | * @param string $uid |
||
151 | * @return mixed |
||
152 | */ |
||
153 | protected function translateUid($uid) { |
||
163 | } |
||
164 |