Google   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 30
ccs 0
cts 8
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getTitle() 0 3 1
A getDefaultScope() 0 3 1
A initUserAttributes() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\AuthClient\Client;
6
7
use Yiisoft\Yii\AuthClient\OAuth2;
8
9
/**
10
 * Google allows authentication via Google OAuth.
11
 *
12
 * In order to use Google OAuth you must create a project at <https://console.developers.google.com/project>
13
 * and setup its credentials at <https://console.developers.google.com/project/[yourProjectId]/apiui/credential>.
14
 * In order to enable using scopes for retrieving user attributes, you should also enable Google+ API at
15
 * <https://console.developers.google.com/project/[yourProjectId]/apiui/api/plus>
16
 *
17
 * @link https://console.developers.google.com/project
18
 */
19
class Google extends OAuth2
20
{
21
    protected string $authUrl = 'https://accounts.google.com/o/oauth2/auth';
22
    protected string $tokenUrl = 'https://accounts.google.com/o/oauth2/token';
23
    protected string $endpoint = 'https://www.googleapis.com/plus/v1';
24
25
    /**
26
     * @return string service name.
27
     */
28
    public function getName(): string
29
    {
30
        return 'google';
31
    }
32
33
    /**
34
     * @return string service title.
35
     */
36
    public function getTitle(): string
37
    {
38
        return 'Google';
39
    }
40
41
    protected function getDefaultScope(): string
42
    {
43
        return 'profile email';
44
    }
45
46
    protected function initUserAttributes(): array
47
    {
48
        return $this->api('people/me', 'GET');
49
    }
50
}
51