These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Spatie\GoogleCalendar; |
||
4 | |||
5 | use Google_Client; |
||
6 | use Google_Service_Calendar; |
||
7 | |||
8 | class GoogleCalendarFactory |
||
9 | { |
||
10 | public static function createForCalendarId(string $calendarId, string $pathToCredentials): GoogleCalendar |
||
11 | { |
||
12 | $config = config('google-calendar'); |
||
0 ignored issues
–
show
|
|||
13 | |||
14 | $client = self::createAuthenticatedGoogleClient($pathToCredentials); |
||
15 | |||
16 | $service = new Google_Service_Calendar($client); |
||
17 | |||
18 | return self::createCalendarClient($service, $calendarId); |
||
19 | } |
||
20 | |||
21 | public static function createAuthenticatedGoogleClient($pathToCredentials): Google_Client |
||
22 | { |
||
23 | $client = new Google_Client; |
||
24 | |||
25 | $client->setScopes([ |
||
26 | Google_Service_Calendar::CALENDAR, |
||
27 | ]); |
||
28 | |||
29 | $client->setAuthConfig($pathToCredentials); |
||
30 | |||
31 | return $client; |
||
32 | } |
||
33 | |||
34 | protected static function createCalendarClient(Google_Service_Calendar $service, string $calendarId): GoogleCalendar |
||
35 | { |
||
36 | return new GoogleCalendar($service, $calendarId); |
||
37 | } |
||
38 | } |
||
39 |
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.