Completed
Push — master ( dfef9a...bfe41e )
by Michał
06:35
created

Twitter::getLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace nyx\auth\id\identities;
2
3
// Internal dependencies
4
use nyx\auth\id\protocols\oauth1;
5
use nyx\auth;
6
7
/**
8
 * Twitter Identity
9
 *
10
 * @package     Nyx\Auth
11
 * @version     0.1.0
12
 * @author      Michal Chojnacki <[email protected]>
13
 * @copyright   2012-2017 Nyx Dev Team
14
 * @link        https://github.com/unyx/nyx
15
 */
16
class Twitter extends oauth1\Identity
17
{
18
    /**
19
     * {@inheritDoc}
20
     */
21
    protected static $provider = oauth1\providers\Twitter::class;
22
23
    /**
24
     * @var string  The description bound to the Identity.
25
     */
26
    protected $description;
27
28
    /**
29
     * @var string  The location bound to the Identity.
30
     */
31
    protected $location;
32
33
    /**
34
     * @var int     The follower count bound to the Identity.
35
     */
36
    protected $followersCount;
37
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function __construct(auth\interfaces\Credentials $credentials, array $data)
42
    {
43
        parent::__construct($credentials, $data);
44
45
        $this->username    = $data['screen_name']             ?? null;
46
        $this->name        = $data['name']                    ?? null;
47
        $this->avatar      = $data['profile_image_url_https'] ?? null;
48
49
        // @todo @decide Check $data['verified'] and discard unverified email addresses?
50
        $this->email       = $data['email']                   ?? null;
51
52
        // Additional data specific to Twitter.
53
        $this->location       = $data['location']              ?? null;
54
        $this->description    = $data['description']           ?? null;
55
        $this->followersCount = (int) $data['followers_count'] ?? null;
56
    }
57
58
    /**
59
     * Returns the description bound to the Identity.
60
     *
61
     * @return  string
62
     */
63
    public function getDescription() : ?string
64
    {
65
        return $this->description;
66
    }
67
68
    /**
69
     * Returns the location bound to the Identity.
70
     *
71
     * @return  string
72
     */
73
    public function getLocation() : ?string
74
    {
75
        return $this->location;
76
    }
77
78
    /**
79
     * Returns the follower count bound to the Identity.
80
     *
81
     * @return  int
82
     */
83
    public function getFollowersCount() : ?int
84
    {
85
        return $this->followersCount;
86
    }
87
}
88