Completed
Push — master ( 881b8c...5e1f80 )
by Iurii
01:21
created

Google::authorize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
/**
4
 * @package Social Login
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2015, Iurii Makukh
7
 * @license https://www.gnu.org/licenses/gpl.html GNU/GPLv3
8
 */
9
10
namespace gplcart\modules\social_login\handlers;
11
12
use gplcart\modules\social_login\handlers\Base as BaseHandler;
13
14
/**
15
 * Contains methods for authorization with Google+
16
 */
17
class Google extends BaseHandler
18
{
19
20
    /**
21
     * Constructor
22
     */
23
    public function __construct()
24
    {
25
        parent::__construct();
26
    }
27
28
    /**
29
     * Process Google+ authorization
30
     * @param array $params
31
     * @param array $provider
32
     * @return mixed
33
     */
34
    public function authorize(array $params, array $provider)
35
    {
36
        $user = $this->request($params, 'https://www.googleapis.com/oauth2/v2/userinfo');
37
38
        if (!empty($user['verified_email'])) {
39
            return $this->submitUser($user, $provider);
40
        }
41
42
        return array();
43
    }
44
45
}
46