Passed
Push — master ( 14fbd7...a7a005 )
by
unknown
55s queued 15s
created
src/Exception/ExceptionInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
  */
13 13
 interface ExceptionInterface
14 14
 {
15
-    /*
15
+	/*
16 16
     ExceptionInterface
17 17
     Exception                                             extends \Exception implements ExceptionInterface
18 18
     |   RuntimeException                                  extends Exception
Please login to merge, or discard this patch.
src/Logger/Psr3LoggerWrapper.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,37 +14,37 @@
 block discarded – undo
14 14
  */
15 15
 class Psr3LoggerWrapper implements LoggerInterface
16 16
 {
17
-    use LoggerAwareTrait;
17
+	use LoggerAwareTrait;
18 18
 
19
-    /**
20
-     * @inheritdoc
21
-     */
22
-    public function info($message, array $context = [])
23
-    {
24
-        $this->logger->info($message, $context);
25
-    }
19
+	/**
20
+	 * @inheritdoc
21
+	 */
22
+	public function info($message, array $context = [])
23
+	{
24
+		$this->logger->info($message, $context);
25
+	}
26 26
 
27
-    /**
28
-     * @inheritdoc
29
-     */
30
-    public function debug($message, array $context = [])
31
-    {
32
-        $this->logger->debug($message, $context);
33
-    }
27
+	/**
28
+	 * @inheritdoc
29
+	 */
30
+	public function debug($message, array $context = [])
31
+	{
32
+		$this->logger->debug($message, $context);
33
+	}
34 34
 
35
-    /**
36
-     * @inheritdoc
37
-     */
38
-    public function error($message, array $context = [])
39
-    {
40
-        $this->logger->error($message, $context);
41
-    }
35
+	/**
36
+	 * @inheritdoc
37
+	 */
38
+	public function error($message, array $context = [])
39
+	{
40
+		$this->logger->error($message, $context);
41
+	}
42 42
 
43
-    /**
44
-     * @inheritdoc
45
-     */
46
-    public function log($level, $message, array $context = [])
47
-    {
48
-        $this->logger->log($level, $message, $context);
49
-    }
43
+	/**
44
+	 * @inheritdoc
45
+	 */
46
+	public function log($level, $message, array $context = [])
47
+	{
48
+		$this->logger->log($level, $message, $context);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
src/Provider/TwitchTV.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
         $data = new Data\Collection($response);
53 53
 
54
-        if (!$data->exists('data')) {
54
+        if ( ! $data->exists('data')) {
55 55
             throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56 56
         }
57 57
 
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -17,66 +17,66 @@
 block discarded – undo
17 17
  */
18 18
 class TwitchTV extends OAuth2
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $scope = 'user:read:email';
24
-
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $apiBaseUrl = 'https://api.twitch.tv/helix/';
29
-
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $authorizeUrl = 'https://id.twitch.tv/oauth2/authorize';
34
-
35
-    /**
36
-     * {@inheritdoc}
37
-     */
38
-    protected $accessTokenUrl = 'https://id.twitch.tv/oauth2/token';
39
-
40
-    /**
41
-     * {@inheritdoc}
42
-     */
43
-    protected $apiDocumentation = 'https://dev.twitch.tv/docs/authentication/';
44
-
45
-    /**
46
-     * {@inheritdoc}
47
-     */
48
-    protected function initialize()
49
-    {
50
-        parent::initialize();
51
-
52
-        $this->apiRequestHeaders['Client-ID'] = $this->clientId;
53
-    }
54
-
55
-    /**
56
-     * {@inheritdoc}
57
-     */
58
-    public function getUserProfile()
59
-    {
60
-        $response = $this->apiRequest('users');
61
-
62
-        $data = new Data\Collection($response);
63
-
64
-        if (!$data->exists('data')) {
65
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
66
-        }
67
-
68
-        $users = $data->filter('data')->values();
69
-        $user = new Data\Collection($users[0]);
70
-
71
-        $userProfile = new User\Profile();
72
-
73
-        $userProfile->identifier = $user->get('id');
74
-        $userProfile->displayName = $user->get('display_name');
75
-        $userProfile->photoURL = $user->get('profile_image_url');
76
-        $userProfile->email = $user->get('email');
77
-        $userProfile->description = strip_tags($user->get('description'));
78
-        $userProfile->profileURL = "https://www.twitch.tv/{$userProfile->displayName}";
79
-
80
-        return $userProfile;
81
-    }
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $scope = 'user:read:email';
24
+
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $apiBaseUrl = 'https://api.twitch.tv/helix/';
29
+
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $authorizeUrl = 'https://id.twitch.tv/oauth2/authorize';
34
+
35
+	/**
36
+	 * {@inheritdoc}
37
+	 */
38
+	protected $accessTokenUrl = 'https://id.twitch.tv/oauth2/token';
39
+
40
+	/**
41
+	 * {@inheritdoc}
42
+	 */
43
+	protected $apiDocumentation = 'https://dev.twitch.tv/docs/authentication/';
44
+
45
+	/**
46
+	 * {@inheritdoc}
47
+	 */
48
+	protected function initialize()
49
+	{
50
+		parent::initialize();
51
+
52
+		$this->apiRequestHeaders['Client-ID'] = $this->clientId;
53
+	}
54
+
55
+	/**
56
+	 * {@inheritdoc}
57
+	 */
58
+	public function getUserProfile()
59
+	{
60
+		$response = $this->apiRequest('users');
61
+
62
+		$data = new Data\Collection($response);
63
+
64
+		if (!$data->exists('data')) {
65
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
66
+		}
67
+
68
+		$users = $data->filter('data')->values();
69
+		$user = new Data\Collection($users[0]);
70
+
71
+		$userProfile = new User\Profile();
72
+
73
+		$userProfile->identifier = $user->get('id');
74
+		$userProfile->displayName = $user->get('display_name');
75
+		$userProfile->photoURL = $user->get('profile_image_url');
76
+		$userProfile->email = $user->get('email');
77
+		$userProfile->description = strip_tags($user->get('description'));
78
+		$userProfile->profileURL = "https://www.twitch.tv/{$userProfile->displayName}";
79
+
80
+		return $userProfile;
81
+	}
82 82
 }
Please login to merge, or discard this patch.
src/Provider/Blizzard.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
         $data = new Data\Collection($response);
53 53
 
54
-        if (!$data->exists('id')) {
54
+        if ( ! $data->exists('id')) {
55 55
             throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56 56
         }
57 57
 
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,49 +17,49 @@
 block discarded – undo
17 17
  */
18 18
 class Blizzard extends OAuth2
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $scope = '';
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $scope = '';
24 24
 
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $apiBaseUrl = 'https://us.battle.net/';
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $apiBaseUrl = 'https://us.battle.net/';
29 29
 
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $authorizeUrl = 'https://us.battle.net/oauth/authorize';
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $authorizeUrl = 'https://us.battle.net/oauth/authorize';
34 34
 
35
-    /**
36
-     * {@inheritdoc}
37
-     */
38
-    protected $accessTokenUrl = 'https://us.battle.net/oauth/token';
35
+	/**
36
+	 * {@inheritdoc}
37
+	 */
38
+	protected $accessTokenUrl = 'https://us.battle.net/oauth/token';
39 39
 
40
-    /**
41
-     * {@inheritdoc}
42
-     */
43
-    protected $apiDocumentation = 'https://develop.battle.net/documentation';
40
+	/**
41
+	 * {@inheritdoc}
42
+	 */
43
+	protected $apiDocumentation = 'https://develop.battle.net/documentation';
44 44
 
45
-    /**
46
-     * {@inheritdoc}
47
-     */
48
-    public function getUserProfile()
49
-    {
50
-        $response = $this->apiRequest('oauth/userinfo');
45
+	/**
46
+	 * {@inheritdoc}
47
+	 */
48
+	public function getUserProfile()
49
+	{
50
+		$response = $this->apiRequest('oauth/userinfo');
51 51
 
52
-        $data = new Data\Collection($response);
52
+		$data = new Data\Collection($response);
53 53
 
54
-        if (!$data->exists('id')) {
55
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56
-        }
54
+		if (!$data->exists('id')) {
55
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56
+		}
57 57
 
58
-        $userProfile = new User\Profile();
58
+		$userProfile = new User\Profile();
59 59
 
60
-        $userProfile->identifier = $data->get('id');
61
-        $userProfile->displayName = $data->get('battletag') ?: $data->get('login');
60
+		$userProfile->identifier = $data->get('id');
61
+		$userProfile->displayName = $data->get('battletag') ?: $data->get('login');
62 62
 
63
-        return $userProfile;
64
-    }
63
+		return $userProfile;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
src/Provider/BlizzardAPAC.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@
 block discarded – undo
17 17
  */
18 18
 class BlizzardAPAC extends Blizzard
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $apiBaseUrl = 'https://apac.battle.net/';
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $apiBaseUrl = 'https://apac.battle.net/';
24 24
 
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $authorizeUrl = 'https://apac.battle.net/oauth/authorize';
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $authorizeUrl = 'https://apac.battle.net/oauth/authorize';
29 29
 
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $accessTokenUrl = 'https://apac.battle.net/oauth/token';
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $accessTokenUrl = 'https://apac.battle.net/oauth/token';
34 34
 }
Please login to merge, or discard this patch.
src/Provider/BlizzardEU.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@
 block discarded – undo
17 17
  */
18 18
 class BlizzardEU extends Blizzard
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $apiBaseUrl = 'https://eu.battle.net/';
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $apiBaseUrl = 'https://eu.battle.net/';
24 24
 
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $authorizeUrl = 'https://eu.battle.net/oauth/authorize';
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $authorizeUrl = 'https://eu.battle.net/oauth/authorize';
29 29
 
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $accessTokenUrl = 'https://eu.battle.net/oauth/token';
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $accessTokenUrl = 'https://eu.battle.net/oauth/token';
34 34
 }
Please login to merge, or discard this patch.
src/Provider/Amazon.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
         $data = new Data\Collection($response);
53 53
 
54
-        if (!$data->exists('user_id')) {
54
+        if ( ! $data->exists('user_id')) {
55 55
             throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56 56
         }
57 57
 
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -17,65 +17,65 @@
 block discarded – undo
17 17
  */
18 18
 class Amazon extends OAuth2
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $scope = 'profile';
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $scope = 'profile';
24 24
 
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $apiBaseUrl = 'https://api.amazon.com/';
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $apiBaseUrl = 'https://api.amazon.com/';
29 29
 
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $authorizeUrl = 'https://www.amazon.com/ap/oa';
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $authorizeUrl = 'https://www.amazon.com/ap/oa';
34 34
 
35
-    /**
36
-     * {@inheritdoc}
37
-     */
38
-    protected $accessTokenUrl = 'https://api.amazon.com/auth/o2/token';
35
+	/**
36
+	 * {@inheritdoc}
37
+	 */
38
+	protected $accessTokenUrl = 'https://api.amazon.com/auth/o2/token';
39 39
 
40
-    /**
41
-     * {@inheritdoc}
42
-     */
43
-    protected $apiDocumentation = 'https://developer.amazon.com/docs/login-with-amazon/documentation-overview.html';
40
+	/**
41
+	 * {@inheritdoc}
42
+	 */
43
+	protected $apiDocumentation = 'https://developer.amazon.com/docs/login-with-amazon/documentation-overview.html';
44 44
 
45
-    /**
46
-     * {@inheritdoc}
47
-     */
48
-    protected function initialize()
49
-    {
50
-        parent::initialize();
45
+	/**
46
+	 * {@inheritdoc}
47
+	 */
48
+	protected function initialize()
49
+	{
50
+		parent::initialize();
51 51
 
52
-        if ($this->isRefreshTokenAvailable()) {
53
-            $this->tokenRefreshParameters += [
54
-                'client_id' => $this->clientId,
55
-                'client_secret' => $this->clientSecret,
56
-            ];
57
-        }
58
-    }
52
+		if ($this->isRefreshTokenAvailable()) {
53
+			$this->tokenRefreshParameters += [
54
+				'client_id' => $this->clientId,
55
+				'client_secret' => $this->clientSecret,
56
+			];
57
+		}
58
+	}
59 59
 
60
-    /**
61
-     * {@inheritdoc}
62
-     */
63
-    public function getUserProfile()
64
-    {
65
-        $response = $this->apiRequest('user/profile');
60
+	/**
61
+	 * {@inheritdoc}
62
+	 */
63
+	public function getUserProfile()
64
+	{
65
+		$response = $this->apiRequest('user/profile');
66 66
 
67
-        $data = new Data\Collection($response);
67
+		$data = new Data\Collection($response);
68 68
 
69
-        if (!$data->exists('user_id')) {
70
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
71
-        }
69
+		if (!$data->exists('user_id')) {
70
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
71
+		}
72 72
 
73
-        $userProfile = new User\Profile();
73
+		$userProfile = new User\Profile();
74 74
 
75
-        $userProfile->identifier = $data->get('user_id');
76
-        $userProfile->displayName = $data->get('name');
77
-        $userProfile->email = $data->get('email');
75
+		$userProfile->identifier = $data->get('user_id');
76
+		$userProfile->displayName = $data->get('name');
77
+		$userProfile->email = $data->get('email');
78 78
 
79
-        return $userProfile;
80
-    }
79
+		return $userProfile;
80
+	}
81 81
 }
Please login to merge, or discard this patch.
src/Provider/QQ.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $response = (new Data\Parser())->parse($res);
91 91
 
92
-        if (!isset($response->openid)) {
92
+        if ( ! isset($response->openid)) {
93 93
             throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
94 94
         }
95 95
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $data = new Data\Collection($response);
117 117
 
118 118
         if ($data->get('ret') < 0) {
119
-            throw new UnexpectedApiResponseException('Provider API returned an error: ' . $data->get('msg'));
119
+            throw new UnexpectedApiResponseException('Provider API returned an error: '.$data->get('msg'));
120 120
         }
121 121
 
122 122
         $userProfile = new Profile();
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -12,127 +12,127 @@
 block discarded – undo
12 12
  */
13 13
 class QQ extends OAuth2
14 14
 {
15
-    /**
16
-     * {@inheritdoc}
17
-     */
18
-    protected $scope = 'get_user_info';
19
-
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $apiBaseUrl = 'https://graph.qq.com/oauth2.0/';
24
-
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $authorizeUrl = 'https://graph.qq.com/oauth2.0/authorize';
29
-
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $accessTokenUrl = 'https://graph.qq.com/oauth2.0/token';
34
-
35
-    /**
36
-     * {@ịnheritdoc}
37
-     */
38
-    protected $accessTokenInfoUrl = 'https://graph.qq.com/oauth2.0/me';
39
-
40
-    /**
41
-     * User Information Endpoint
42
-     * @var string
43
-     */
44
-    protected $accessUserInfo = 'https://graph.qq.com/user/get_user_info';
45
-
46
-    /**
47
-     * {@inheritdoc}
48
-     */
49
-    protected $tokenExchangeMethod = 'GET';
50
-
51
-    /**
52
-     * {@inheritdoc}
53
-     */
54
-    protected $tokenRefreshMethod = 'GET';
55
-
56
-    /**
57
-     * {@inheritdoc}
58
-     */
59
-    protected $apiDocumentation = ''; // Not available
60
-
61
-    /**
62
-     * {@inheritdoc}
63
-     */
64
-    protected function initialize()
65
-    {
66
-        parent::initialize();
67
-
68
-        if ($this->isRefreshTokenAvailable()) {
69
-            $this->tokenRefreshParameters += [
70
-                'client_id' => $this->clientId,
71
-                'client_secret' => $this->clientSecret,
72
-            ];
73
-        }
74
-
75
-        $this->apiRequestParameters = [
76
-            'access_token' => $this->getStoredData('access_token')
77
-        ];
78
-
79
-        $this->apiRequestHeaders = [];
80
-    }
81
-
82
-    /**
83
-     * {@inheritdoc}
84
-     */
85
-    protected function validateAccessTokenExchange($response)
86
-    {
87
-        $collection = parent::validateAccessTokenExchange($response);
88
-
89
-        $resp = $this->apiRequest($this->accessTokenInfoUrl);
90
-        $resp = key($resp);
91
-
92
-        $len = strlen($resp);
93
-        $res = substr($resp, 10, $len - 14);
94
-
95
-        $response = (new Data\Parser())->parse($res);
96
-
97
-        if (!isset($response->openid)) {
98
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
99
-        }
100
-
101
-        $this->storeData('openid', $response->openid);
102
-
103
-        return $collection;
104
-    }
105
-
106
-    /**
107
-     * {@inheritdoc}
108
-     */
109
-    public function getUserProfile()
110
-    {
111
-        $openid = $this->getStoredData('openid');
112
-
113
-        $userRequestParameters = [
114
-            'oauth_consumer_key' => $this->clientId,
115
-            'openid' => $openid,
116
-            'format' => 'json'
117
-        ];
118
-
119
-        $response = $this->apiRequest($this->accessUserInfo, 'GET', $userRequestParameters);
120
-
121
-        $data = new Data\Collection($response);
122
-
123
-        if ($data->get('ret') < 0) {
124
-            throw new UnexpectedApiResponseException('Provider API returned an error: ' . $data->get('msg'));
125
-        }
126
-
127
-        $userProfile = new Profile();
128
-
129
-        $userProfile->identifier = $openid;
130
-        $userProfile->displayName = $data->get('nickname');
131
-        $userProfile->photoURL = $data->get('figureurl_2');
132
-        $userProfile->gender = $data->get('gender');
133
-        $userProfile->region = $data->get('province');
134
-        $userProfile->city = $data->get('city');
135
-
136
-        return $userProfile;
137
-    }
15
+	/**
16
+	 * {@inheritdoc}
17
+	 */
18
+	protected $scope = 'get_user_info';
19
+
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $apiBaseUrl = 'https://graph.qq.com/oauth2.0/';
24
+
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $authorizeUrl = 'https://graph.qq.com/oauth2.0/authorize';
29
+
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $accessTokenUrl = 'https://graph.qq.com/oauth2.0/token';
34
+
35
+	/**
36
+	 * {@ịnheritdoc}
37
+	 */
38
+	protected $accessTokenInfoUrl = 'https://graph.qq.com/oauth2.0/me';
39
+
40
+	/**
41
+	 * User Information Endpoint
42
+	 * @var string
43
+	 */
44
+	protected $accessUserInfo = 'https://graph.qq.com/user/get_user_info';
45
+
46
+	/**
47
+	 * {@inheritdoc}
48
+	 */
49
+	protected $tokenExchangeMethod = 'GET';
50
+
51
+	/**
52
+	 * {@inheritdoc}
53
+	 */
54
+	protected $tokenRefreshMethod = 'GET';
55
+
56
+	/**
57
+	 * {@inheritdoc}
58
+	 */
59
+	protected $apiDocumentation = ''; // Not available
60
+
61
+	/**
62
+	 * {@inheritdoc}
63
+	 */
64
+	protected function initialize()
65
+	{
66
+		parent::initialize();
67
+
68
+		if ($this->isRefreshTokenAvailable()) {
69
+			$this->tokenRefreshParameters += [
70
+				'client_id' => $this->clientId,
71
+				'client_secret' => $this->clientSecret,
72
+			];
73
+		}
74
+
75
+		$this->apiRequestParameters = [
76
+			'access_token' => $this->getStoredData('access_token')
77
+		];
78
+
79
+		$this->apiRequestHeaders = [];
80
+	}
81
+
82
+	/**
83
+	 * {@inheritdoc}
84
+	 */
85
+	protected function validateAccessTokenExchange($response)
86
+	{
87
+		$collection = parent::validateAccessTokenExchange($response);
88
+
89
+		$resp = $this->apiRequest($this->accessTokenInfoUrl);
90
+		$resp = key($resp);
91
+
92
+		$len = strlen($resp);
93
+		$res = substr($resp, 10, $len - 14);
94
+
95
+		$response = (new Data\Parser())->parse($res);
96
+
97
+		if (!isset($response->openid)) {
98
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
99
+		}
100
+
101
+		$this->storeData('openid', $response->openid);
102
+
103
+		return $collection;
104
+	}
105
+
106
+	/**
107
+	 * {@inheritdoc}
108
+	 */
109
+	public function getUserProfile()
110
+	{
111
+		$openid = $this->getStoredData('openid');
112
+
113
+		$userRequestParameters = [
114
+			'oauth_consumer_key' => $this->clientId,
115
+			'openid' => $openid,
116
+			'format' => 'json'
117
+		];
118
+
119
+		$response = $this->apiRequest($this->accessUserInfo, 'GET', $userRequestParameters);
120
+
121
+		$data = new Data\Collection($response);
122
+
123
+		if ($data->get('ret') < 0) {
124
+			throw new UnexpectedApiResponseException('Provider API returned an error: ' . $data->get('msg'));
125
+		}
126
+
127
+		$userProfile = new Profile();
128
+
129
+		$userProfile->identifier = $openid;
130
+		$userProfile->displayName = $data->get('nickname');
131
+		$userProfile->photoURL = $data->get('figureurl_2');
132
+		$userProfile->gender = $data->get('gender');
133
+		$userProfile->region = $data->get('province');
134
+		$userProfile->city = $data->get('city');
135
+
136
+		return $userProfile;
137
+	}
138 138
 }
Please login to merge, or discard this patch.
src/Provider/GitHub.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         $data = new Data\Collection($response);
54 54
 
55
-        if (!$data->exists('id')) {
55
+        if ( ! $data->exists('id')) {
56 56
             throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
57 57
         }
58 58
 
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
         $response = $this->apiRequest('user/emails');
96 96
 
97 97
         foreach ($response as $idx => $item) {
98
-            if (!empty($item->primary) && $item->primary == 1) {
98
+            if ( ! empty($item->primary) && $item->primary == 1) {
99 99
                 $userProfile->email = $item->email;
100 100
 
101
-                if (!empty($item->verified) && $item->verified == 1) {
101
+                if ( ! empty($item->verified) && $item->verified == 1) {
102 102
                     $userProfile->emailVerified = $userProfile->email;
103 103
                 }
104 104
 
Please login to merge, or discard this patch.
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -17,94 +17,94 @@
 block discarded – undo
17 17
  */
18 18
 class GitHub extends OAuth2
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $scope = 'user:email';
24
-
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $apiBaseUrl = 'https://api.github.com/';
29
-
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $authorizeUrl = 'https://github.com/login/oauth/authorize';
34
-
35
-    /**
36
-     * {@inheritdoc}
37
-     */
38
-    protected $accessTokenUrl = 'https://github.com/login/oauth/access_token';
39
-
40
-    /**
41
-     * {@inheritdoc}
42
-     */
43
-    protected $apiDocumentation = 'https://developer.github.com/v3/oauth/';
44
-
45
-    /**
46
-     * {@inheritdoc}
47
-     */
48
-    public function getUserProfile()
49
-    {
50
-        $response = $this->apiRequest('user');
51
-
52
-        $data = new Data\Collection($response);
53
-
54
-        if (!$data->exists('id')) {
55
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56
-        }
57
-
58
-        $userProfile = new User\Profile();
59
-
60
-        $userProfile->identifier = $data->get('id');
61
-        $userProfile->displayName = $data->get('name');
62
-        $userProfile->description = $data->get('bio');
63
-        $userProfile->photoURL = $data->get('avatar_url');
64
-        $userProfile->profileURL = $data->get('html_url');
65
-        $userProfile->email = $data->get('email');
66
-        $userProfile->webSiteURL = $data->get('blog');
67
-        $userProfile->region = $data->get('location');
68
-
69
-        $userProfile->displayName = $userProfile->displayName ?: $data->get('login');
70
-
71
-        if (empty($userProfile->email) && strpos($this->scope, 'user:email') !== false) {
72
-            try {
73
-                // user email is not mandatory so keep it quite.
74
-                $userProfile = $this->requestUserEmail($userProfile);
75
-            } catch (\Exception $e) {
76
-            }
77
-        }
78
-
79
-        return $userProfile;
80
-    }
81
-
82
-    /**
83
-     * Request connected user email
84
-     *
85
-     * https://developer.github.com/v3/users/emails/
86
-     * @param User\Profile $userProfile
87
-     *
88
-     * @return User\Profile
89
-     *
90
-     * @throws \Exception
91
-     */
92
-    protected function requestUserEmail(User\Profile $userProfile)
93
-    {
94
-        $response = $this->apiRequest('user/emails');
95
-
96
-        foreach ($response as $idx => $item) {
97
-            if (!empty($item->primary) && $item->primary == 1) {
98
-                $userProfile->email = $item->email;
99
-
100
-                if (!empty($item->verified) && $item->verified == 1) {
101
-                    $userProfile->emailVerified = $userProfile->email;
102
-                }
103
-
104
-                break;
105
-            }
106
-        }
107
-
108
-        return $userProfile;
109
-    }
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $scope = 'user:email';
24
+
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $apiBaseUrl = 'https://api.github.com/';
29
+
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $authorizeUrl = 'https://github.com/login/oauth/authorize';
34
+
35
+	/**
36
+	 * {@inheritdoc}
37
+	 */
38
+	protected $accessTokenUrl = 'https://github.com/login/oauth/access_token';
39
+
40
+	/**
41
+	 * {@inheritdoc}
42
+	 */
43
+	protected $apiDocumentation = 'https://developer.github.com/v3/oauth/';
44
+
45
+	/**
46
+	 * {@inheritdoc}
47
+	 */
48
+	public function getUserProfile()
49
+	{
50
+		$response = $this->apiRequest('user');
51
+
52
+		$data = new Data\Collection($response);
53
+
54
+		if (!$data->exists('id')) {
55
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56
+		}
57
+
58
+		$userProfile = new User\Profile();
59
+
60
+		$userProfile->identifier = $data->get('id');
61
+		$userProfile->displayName = $data->get('name');
62
+		$userProfile->description = $data->get('bio');
63
+		$userProfile->photoURL = $data->get('avatar_url');
64
+		$userProfile->profileURL = $data->get('html_url');
65
+		$userProfile->email = $data->get('email');
66
+		$userProfile->webSiteURL = $data->get('blog');
67
+		$userProfile->region = $data->get('location');
68
+
69
+		$userProfile->displayName = $userProfile->displayName ?: $data->get('login');
70
+
71
+		if (empty($userProfile->email) && strpos($this->scope, 'user:email') !== false) {
72
+			try {
73
+				// user email is not mandatory so keep it quite.
74
+				$userProfile = $this->requestUserEmail($userProfile);
75
+			} catch (\Exception $e) {
76
+			}
77
+		}
78
+
79
+		return $userProfile;
80
+	}
81
+
82
+	/**
83
+	 * Request connected user email
84
+	 *
85
+	 * https://developer.github.com/v3/users/emails/
86
+	 * @param User\Profile $userProfile
87
+	 *
88
+	 * @return User\Profile
89
+	 *
90
+	 * @throws \Exception
91
+	 */
92
+	protected function requestUserEmail(User\Profile $userProfile)
93
+	{
94
+		$response = $this->apiRequest('user/emails');
95
+
96
+		foreach ($response as $idx => $item) {
97
+			if (!empty($item->primary) && $item->primary == 1) {
98
+				$userProfile->email = $item->email;
99
+
100
+				if (!empty($item->verified) && $item->verified == 1) {
101
+					$userProfile->emailVerified = $userProfile->email;
102
+				}
103
+
104
+				break;
105
+			}
106
+		}
107
+
108
+		return $userProfile;
109
+	}
110 110
 }
Please login to merge, or discard this patch.