Completed
Push — master ( 50beb4...8d6a23 )
by Michał
02:12
created

Slack::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 2
1
<?php namespace nyx\auth\id\identities;
2
3
// Internal dependencies
4
use nyx\auth\id\protocols\oauth2;
5
6
/**
7
 * Slack 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 Slack extends oauth2\Identity
16
{
17
    /**
18
     * {@inheritDoc}
19
     */
20
    protected static $provider = oauth2\providers\Slack::class;
21
22
    /**
23
     * @var string  The identifier of the Team this Identity belongs to (and which provides its access context).
24
     */
25
    protected $teamId;
26
27
    /**
28
     * @var string  The name of the Team this Identity belongs to (and which provides its access context).
29
     */
30
    protected $teamName;
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    public function __construct(oauth2\Token $token, array $data)
36
    {
37
        $this->id     = $data['user']['id']         ?? null;
38
        $this->email  = $data['user']['email']      ?? '';
39
        $this->name   = $data['user']['name']       ?? '';
40
        $this->avatar = $data['user']['image_192']  ?? '';
41
42
        $this->teamId   = $data['team']['id']       ?? '';
43
        $this->teamName = $data['team']['name']     ?? '';
44
45
        parent::__construct($token, $data);
46
    }
47
}
48