1 | <?php |
||
15 | class AzineHybridAuth |
||
16 | { |
||
17 | /** |
||
18 | * ID of the sessionDataCookie. |
||
19 | */ |
||
20 | const cookieName = 'azine_hybridauth_session'; |
||
21 | |||
22 | /** |
||
23 | * @var ObjectManager |
||
24 | */ |
||
25 | private $objectManager; |
||
26 | |||
27 | /** |
||
28 | * @var UserInterface |
||
29 | */ |
||
30 | private $currentUser; |
||
31 | |||
32 | /** |
||
33 | * @var bool |
||
34 | */ |
||
35 | private $storeForUser; |
||
36 | |||
37 | /** |
||
38 | * @var bool |
||
39 | */ |
||
40 | private $storeAsCookie; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | private $expiresInDays; |
||
46 | |||
47 | /** |
||
48 | * Configured Instances of HybridAuth. |
||
49 | * |
||
50 | * @var array or HybridAuth |
||
51 | */ |
||
52 | private $instances = array(); |
||
53 | |||
54 | /** |
||
55 | * HybridAuth configuration. |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | private $config; |
||
60 | |||
61 | /** |
||
62 | * @param UrlGeneratorInterface $router |
||
63 | * @param TokenStorageInterface $tokenStorage |
||
64 | * @param ObjectManager $manager |
||
65 | * @param array $config |
||
66 | * @param bool $storeForUser |
||
67 | 2 | * @param $storeAsCookie |
|
68 | 2 | * @param $expiresInDays |
|
69 | 2 | */ |
|
70 | 2 | public function __construct(UrlGeneratorInterface $router, TokenStorageInterface $tokenStorage, ObjectManager $manager, $config, $storeForUser, $storeAsCookie, $expiresInDays) |
|
85 | |||
86 | /** |
||
87 | * Get a AdapterInterface instance initialised for the given provider. |
||
88 | * HybridAuthSessions will be restored from DB and/or cookies, according to the bundle configuration. |
||
89 | * |
||
90 | * @param $cookieSessionData |
||
91 | * @param $provider |
||
92 | * |
||
93 | * @return \Hybridauth\Adapter\AdapterInterface |
||
94 | */ |
||
95 | public function getInstance($cookieSessionData, $provider) |
||
144 | |||
145 | /** |
||
146 | * @param Request $request |
||
147 | * @param $provider |
||
148 | * @param $sessionData |
||
149 | * |
||
150 | * @return Cookie | null |
||
151 | */ |
||
152 | public function storeHybridAuthSessionData(Request $request, $provider, $sessionData) |
||
162 | |||
163 | /** |
||
164 | * Delete the HybridAuthSessionData entity from the database. |
||
165 | * |
||
166 | * @param $provider |
||
167 | */ |
||
168 | public function deleteSession($provider) |
||
178 | |||
179 | /** |
||
180 | * Save as HybridAuthSessionData entity to the database. |
||
181 | * Checks the bundle configuration before saving. |
||
182 | * |
||
183 | * @param $sessionData |
||
184 | * @param $provider |
||
185 | */ |
||
186 | private function saveAuthSessionData($sessionData, $provider) |
||
205 | |||
206 | public function getCookieName($provider) |
||
210 | |||
211 | /** |
||
212 | * Use this function to get access to a \Hybridauth\Adapter\AdapterInterface instance. |
||
213 | * |
||
214 | * Calling this method will log the user in (make a roundtrip to the providers site and back to your site again) |
||
215 | * and call the page again that you came from. |
||
216 | * |
||
217 | * When logged (allready) it will return the hybridAuth provider. |
||
218 | * |
||
219 | * @param $authSessionData |
||
220 | * @param string $provider_id |
||
221 | * @param bool $require_login |
||
222 | * |
||
223 | * @return \Hybridauth\Adapter\AdapterInterface |
||
224 | */ |
||
225 | public function getProvider($authSessionData, $provider_id, $require_login = true) |
||
234 | |||
235 | /** |
||
236 | * Check if the current user has allowed access to the given provider. |
||
237 | * |
||
238 | * @param Request $request |
||
239 | * @param string $provider_id |
||
240 | * |
||
241 | * @return bool true if access to the provider is granted for this app |
||
242 | */ |
||
243 | public function isConnected(Request $request, $provider_id) |
||
251 | |||
252 | /** |
||
253 | * Get the LinkedIn Adapter. |
||
254 | * |
||
255 | * @return \Hybrid_Providers_LinkedIn |
||
256 | */ |
||
257 | public function getLinkedIn() |
||
261 | |||
262 | /** |
||
263 | * Get the LinkedIn api (LinkedIn PHP-client). |
||
264 | * |
||
265 | * @return \LinkedIn |
||
266 | */ |
||
267 | 2 | public function getLinkedInApi() |
|
271 | 1 | ||
272 | /** |
||
273 | * Get if auth token is expired. |
||
274 | 1 | * |
|
275 | * @param HybridAuthSessionData $data |
||
276 | * |
||
277 | * @return bool |
||
278 | */ |
||
279 | public function isExpiredSession(HybridAuthSessionData $data) |
||
287 | } |
||
288 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.