Passed
Push — master ( 3948f8...d3c224 )
by Dāvis
07:09
created

TwitterUser::returnsEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Oauth\Client\Provider\Twitter;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
use Sludio\HelperBundle\Oauth\Component\SocialUserInterface;
7
8
class TwitterUser implements ResourceOwnerInterface, SocialUserInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $response;
14
15
    /**
16
     * @var integer
17
     */
18
    protected $id;
19
20
    /**
21
     * @var string
22
     */
23
    protected $email;
24
25
    /**
26
     * @var string
27
     */
28
    protected $firstName;
29
30
    /**
31
     * @var string
32
     */
33
    protected $lastName;
34
35
    /**
36
     * @var string
37
     */
38
    protected $username;
39
40
    /**
41
     * @var bool
42
     */
43
    protected $returnsEmail = false;
44
45
    /**
46
     * @return bool
47
     */
48
    public function returnsEmail()
49
    {
50
        return $this->returnsEmail;
51
    }
52
53
    /**
54
     * @param  array $response
55
     */
56
    public function __construct(array $response)
57
    {
58
        $this->response = $response;
59
60
        $this->id = (int)$this->response['user_id'];
61
62
        if (isset($this->response['email'])) {
63
            $this->email = $this->response['email'];
64
        }
65
66
        $this->username = preg_replace('/[^a-z\d]/i', '', $this->response['screen_name']);
67
    }
68
69
    /**
70
     * Returns all the data obtained about the user.
71
     *
72
     * @return array
73
     */
74
    public function toArray()
75
    {
76
        return $this->response;
77
    }
78
79
    /**
80
     * Get the value of Id
81
     *
82
     * @return integer
83
     */
84
    public function getId()
85
    {
86
        return $this->id;
87
    }
88
89
    /**
90
     * Get the value of Email
91
     *
92
     * @return string
93
     */
94
    public function getEmail()
95
    {
96
        return $this->email;
97
    }
98
99
    /**
100
     * Get the value of First Name
101
     *
102
     * @return string
103
     */
104
    public function getFirstName()
105
    {
106
        return $this->firstName;
107
    }
108
109
    /**
110
     * Get the value of Last Name
111
     *
112
     * @return string
113
     */
114
    public function getLastName()
115
    {
116
        return $this->lastName;
117
    }
118
119
    /**
120
     * Get the value of Username
121
     *
122
     * @return string
123
     */
124
    public function getUsername()
125
    {
126
        return $this->username;
127
    }
128
}
129