Completed
Push — master ( d7683b...50beb4 )
by Michał
02:17
created

Google   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php namespace nyx\auth\id\identities;
2
3
// Internal dependencies
4
use nyx\auth\id\protocols\oauth2;
5
6
/**
7
 * Google Identity
8
 *
9
 * @package     Nyx\Auth
10
 * @version     0.1.0
11
 * @author      Michal Chojnacki <[email protected]>
12
 * @copyright   2012-2017 Nyx Dev Team
13
 * @link        https://github.com/unyx/nyx
14
 */
15
class Google extends oauth2\Identity
16
{
17
    /**
18
     * {@inheritDoc}
19
     */
20
    protected static $provider = oauth2\providers\Google::class;
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function __construct(oauth2\Token $token, array $data)
26
    {
27
        parent::__construct($token, $data);
28
29
        $this->username = $data['nickname']           ?? null;
30
        $this->name     = $data['displayName']        ?? null;
31
        $this->email    = $data['emails'][0]['value'] ?? null;
32
33
        if (isset($data['image'])) {
34
            $this->avatar = $data['image']['url']     ?? null;
35
        }
36
    }
37
}
38