Passed
Push — master ( bd5724...8a312b )
by
unknown
01:47
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/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   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -17,109 +17,109 @@
 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
-    protected function initialize()
49
-    {
50
-        parent::initialize();
51
-
52
-        if ($this->isRefreshTokenAvailable()) {
53
-            $this->tokenRefreshParameters += [
54
-                'client_id' => $this->clientId,
55
-                'client_secret' => $this->clientSecret
56
-            ];
57
-        }
58
-    }
59
-
60
-    /**
61
-     * {@inheritdoc}
62
-     */
63
-    public function getUserProfile()
64
-    {
65
-        $response = $this->apiRequest('user');
66
-
67
-        $data = new Data\Collection($response);
68
-
69
-        if (!$data->exists('id')) {
70
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
71
-        }
72
-
73
-        $userProfile = new User\Profile();
74
-
75
-        $userProfile->identifier = $data->get('id');
76
-        $userProfile->displayName = $data->get('name');
77
-        $userProfile->description = $data->get('bio');
78
-        $userProfile->photoURL = $data->get('avatar_url');
79
-        $userProfile->profileURL = $data->get('html_url');
80
-        $userProfile->email = $data->get('email');
81
-        $userProfile->webSiteURL = $data->get('blog');
82
-        $userProfile->region = $data->get('location');
83
-
84
-        $userProfile->displayName = $userProfile->displayName ?: $data->get('login');
85
-
86
-        if (empty($userProfile->email) && strpos($this->scope, 'user:email') !== false) {
87
-            try {
88
-                // user email is not mandatory so keep it quite.
89
-                $userProfile = $this->requestUserEmail($userProfile);
90
-            } catch (\Exception $e) {
91
-            }
92
-        }
93
-
94
-        return $userProfile;
95
-    }
96
-
97
-    /**
98
-     * Request connected user email
99
-     *
100
-     * https://developer.github.com/v3/users/emails/
101
-     * @param User\Profile $userProfile
102
-     *
103
-     * @return User\Profile
104
-     *
105
-     * @throws \Exception
106
-     */
107
-    protected function requestUserEmail(User\Profile $userProfile)
108
-    {
109
-        $response = $this->apiRequest('user/emails');
110
-
111
-        foreach ($response as $idx => $item) {
112
-            if (!empty($item->primary) && $item->primary == 1) {
113
-                $userProfile->email = $item->email;
114
-
115
-                if (!empty($item->verified) && $item->verified == 1) {
116
-                    $userProfile->emailVerified = $userProfile->email;
117
-                }
118
-
119
-                break;
120
-            }
121
-        }
122
-
123
-        return $userProfile;
124
-    }
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
+	protected function initialize()
49
+	{
50
+		parent::initialize();
51
+
52
+		if ($this->isRefreshTokenAvailable()) {
53
+			$this->tokenRefreshParameters += [
54
+				'client_id' => $this->clientId,
55
+				'client_secret' => $this->clientSecret
56
+			];
57
+		}
58
+	}
59
+
60
+	/**
61
+	 * {@inheritdoc}
62
+	 */
63
+	public function getUserProfile()
64
+	{
65
+		$response = $this->apiRequest('user');
66
+
67
+		$data = new Data\Collection($response);
68
+
69
+		if (!$data->exists('id')) {
70
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
71
+		}
72
+
73
+		$userProfile = new User\Profile();
74
+
75
+		$userProfile->identifier = $data->get('id');
76
+		$userProfile->displayName = $data->get('name');
77
+		$userProfile->description = $data->get('bio');
78
+		$userProfile->photoURL = $data->get('avatar_url');
79
+		$userProfile->profileURL = $data->get('html_url');
80
+		$userProfile->email = $data->get('email');
81
+		$userProfile->webSiteURL = $data->get('blog');
82
+		$userProfile->region = $data->get('location');
83
+
84
+		$userProfile->displayName = $userProfile->displayName ?: $data->get('login');
85
+
86
+		if (empty($userProfile->email) && strpos($this->scope, 'user:email') !== false) {
87
+			try {
88
+				// user email is not mandatory so keep it quite.
89
+				$userProfile = $this->requestUserEmail($userProfile);
90
+			} catch (\Exception $e) {
91
+			}
92
+		}
93
+
94
+		return $userProfile;
95
+	}
96
+
97
+	/**
98
+	 * Request connected user email
99
+	 *
100
+	 * https://developer.github.com/v3/users/emails/
101
+	 * @param User\Profile $userProfile
102
+	 *
103
+	 * @return User\Profile
104
+	 *
105
+	 * @throws \Exception
106
+	 */
107
+	protected function requestUserEmail(User\Profile $userProfile)
108
+	{
109
+		$response = $this->apiRequest('user/emails');
110
+
111
+		foreach ($response as $idx => $item) {
112
+			if (!empty($item->primary) && $item->primary == 1) {
113
+				$userProfile->email = $item->email;
114
+
115
+				if (!empty($item->verified) && $item->verified == 1) {
116
+					$userProfile->emailVerified = $userProfile->email;
117
+				}
118
+
119
+				break;
120
+			}
121
+		}
122
+
123
+		return $userProfile;
124
+	}
125 125
 }
Please login to merge, or discard this patch.
src/Exception/Exception.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
             $obj_dump = print_r($object, true);
50 50
 
51 51
             // phpcs:ignore
52
-            $html .= sprintf('<b>' . get_class($object) . '</b> extends <b>' . get_parent_class($object) . '</b><pre>%s</pre>', $obj_dump);
52
+            $html .= sprintf('<b>'.get_class($object).'</b> extends <b>'.get_parent_class($object).'</b><pre>%s</pre>', $obj_dump);
53 53
         }
54 54
 
55 55
         $html .= '<h2>Session</h2>';
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -12,53 +12,53 @@
 block discarded – undo
12 12
  */
13 13
 class Exception extends \Exception implements ExceptionInterface
14 14
 {
15
-    /**
16
-     * Shamelessly Borrowed from Slimframework
17
-     *
18
-     * @param $object
19
-     */
20
-    public function debug($object)
21
-    {
22
-        $title = 'Hybridauth Exception';
23
-        $code = $this->getCode();
24
-        $message = $this->getMessage();
25
-        $file = $this->getFile();
26
-        $line = $this->getLine();
27
-        $trace = $this->getTraceAsString();
15
+	/**
16
+	 * Shamelessly Borrowed from Slimframework
17
+	 *
18
+	 * @param $object
19
+	 */
20
+	public function debug($object)
21
+	{
22
+		$title = 'Hybridauth Exception';
23
+		$code = $this->getCode();
24
+		$message = $this->getMessage();
25
+		$file = $this->getFile();
26
+		$line = $this->getLine();
27
+		$trace = $this->getTraceAsString();
28 28
 
29
-        $html = sprintf('<h1>%s</h1>', $title);
30
-        $html .= '<p>Hybridauth has encountered the following error:</p>';
31
-        $html .= '<h2>Details</h2>';
29
+		$html = sprintf('<h1>%s</h1>', $title);
30
+		$html .= '<p>Hybridauth has encountered the following error:</p>';
31
+		$html .= '<h2>Details</h2>';
32 32
 
33
-        $html .= sprintf('<div><strong>Exception:</strong> %s</div>', get_class($this));
33
+		$html .= sprintf('<div><strong>Exception:</strong> %s</div>', get_class($this));
34 34
 
35
-        $html .= sprintf('<div><strong>Message:</strong> <font color="#cc0000">%s</font></div>', $message);
35
+		$html .= sprintf('<div><strong>Message:</strong> <font color="#cc0000">%s</font></div>', $message);
36 36
 
37
-        $html .= sprintf('<div><strong>File:</strong> %s</div>', $file);
37
+		$html .= sprintf('<div><strong>File:</strong> %s</div>', $file);
38 38
 
39
-        $html .= sprintf('<div><strong>Line:</strong> %s</div>', $line);
39
+		$html .= sprintf('<div><strong>Line:</strong> %s</div>', $line);
40 40
 
41
-        $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
41
+		$html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
42 42
 
43
-        $html .= '<h2>Trace</h2>';
44
-        $html .= sprintf('<pre>%s</pre>', $trace);
43
+		$html .= '<h2>Trace</h2>';
44
+		$html .= sprintf('<pre>%s</pre>', $trace);
45 45
 
46
-        if ($object) {
47
-            $html .= '<h2>Debug</h2>';
46
+		if ($object) {
47
+			$html .= '<h2>Debug</h2>';
48 48
 
49
-            $obj_dump = print_r($object, true);
49
+			$obj_dump = print_r($object, true);
50 50
 
51
-            // phpcs:ignore
52
-            $html .= sprintf('<b>' . get_class($object) . '</b> extends <b>' . get_parent_class($object) . '</b><pre>%s</pre>', $obj_dump);
53
-        }
51
+			// phpcs:ignore
52
+			$html .= sprintf('<b>' . get_class($object) . '</b> extends <b>' . get_parent_class($object) . '</b><pre>%s</pre>', $obj_dump);
53
+		}
54 54
 
55
-        $html .= '<h2>Session</h2>';
55
+		$html .= '<h2>Session</h2>';
56 56
 
57
-        $session_dump = print_r($_SESSION, true);
57
+		$session_dump = print_r($_SESSION, true);
58 58
 
59
-        $html .= sprintf('<pre>%s</pre>', $session_dump);
59
+		$html .= sprintf('<pre>%s</pre>', $session_dump);
60 60
 
61
-        // phpcs:ignore
62
-        echo sprintf("<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:75px;}</style></head><body>%s</body></html>", $title, $html);
63
-    }
61
+		// phpcs:ignore
62
+		echo sprintf("<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:75px;}</style></head><body>%s</body></html>", $title, $html);
63
+	}
64 64
 }
Please login to merge, or discard this patch.