1 | <?php |
||
16 | class ThreemaGateway_Handler_Settings |
||
17 | { |
||
18 | /** |
||
19 | * @var string $gatewayId Your own Threema Gateway ID |
||
20 | */ |
||
21 | protected $gatewayId = ''; |
||
22 | |||
23 | /** |
||
24 | * @var string $gatewaySecret Your own Threema Gateway secret |
||
25 | */ |
||
26 | protected $gatewaySecret = ''; |
||
27 | |||
28 | /** |
||
29 | * @var string $privateKey Your own private key |
||
30 | */ |
||
31 | protected $privateKey = ''; |
||
32 | |||
33 | /** |
||
34 | * @var string $privateKeyBase The unconverted private key from settings. |
||
35 | */ |
||
36 | private $privateKeyBase = ''; |
||
37 | |||
38 | /** |
||
39 | * @var string $publicKey the public key converted from the private key {@see $privateKey} |
||
40 | */ |
||
41 | protected $publicKey = ''; |
||
42 | |||
43 | /** |
||
44 | * Initiate settings. |
||
45 | */ |
||
46 | public function __construct() |
||
67 | |||
68 | /** |
||
69 | * Checks whether the Gateway is basically set up. |
||
70 | * |
||
71 | * Note that this may not check all requirements (like installed libsodium |
||
72 | * and so on). |
||
73 | * In contrast to {@link isReady()} this only checks whether it is possible |
||
74 | * to query the Threema Server for data, not whether sending/receiving |
||
75 | * messages is actually possible. |
||
76 | * This does not check any permissions! Use |
||
77 | * {@link ThreemaGateway_Handler_Permissions->hasPermission()} for this |
||
78 | * instead! |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | public function isAvaliable() |
||
93 | |||
94 | /** |
||
95 | * Checks whether everything is comple, so sending and receiving messages |
||
96 | * is (theoretically) possible. |
||
97 | * |
||
98 | * This includes {@link isAvaliable()} as a basic check. |
||
99 | * This does not check any permissions! Use |
||
100 | * {@link ThreemaGateway_Handler_Permissions->hasPermission()} for this |
||
101 | * instead! |
||
102 | * |
||
103 | * @return bool |
||
104 | */ |
||
105 | public function isReady() |
||
137 | |||
138 | /** |
||
139 | * Checks whether sending uses the end-to-end encrypted mode. |
||
140 | * |
||
141 | * Note: When E2E mode is not used it is also not possible to receive |
||
142 | * messages. |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function isEndToEnd() |
||
150 | |||
151 | /** |
||
152 | * Checks whether the Gateway is running in debug mode. |
||
153 | * |
||
154 | * You may use this to show scary messages to the admins ;-) or to |
||
155 | * conditionally disable functionality. |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | public function isDebug() |
||
168 | |||
169 | /** |
||
170 | * Returns the gateway ID. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getId() |
||
178 | |||
179 | /** |
||
180 | * Returns the gateway secret. |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | public function getSecret() |
||
188 | |||
189 | /** |
||
190 | * Returns the private key. |
||
191 | * |
||
192 | * @return string |
||
193 | */ |
||
194 | public function getPrivateKey() |
||
202 | |||
203 | /** |
||
204 | * Returns the public key. |
||
205 | * |
||
206 | * @return string |
||
207 | */ |
||
208 | public function getOwnPublicKey() |
||
218 | |||
219 | /** |
||
220 | * Checks and processes the private key. Throws an exception if something |
||
221 | * is wrong. |
||
222 | * |
||
223 | * @throws XenForo_Exception |
||
224 | */ |
||
225 | protected function convertPrivateKey() |
||
251 | |||
252 | /** |
||
253 | * Checks whether the string actually is a private key. |
||
254 | * |
||
255 | * @param string $privateKey The string to check. |
||
256 | * @return bool |
||
257 | */ |
||
258 | protected function isPrivateKey($privateKey) |
||
262 | |||
263 | /** |
||
264 | * Convert object to string. |
||
265 | * |
||
266 | * @return string |
||
267 | */ |
||
268 | public function __toString() |
||
272 | } |
||
273 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.