TwitterUser   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 116
rs 10
c 0
b 0
f 0
wmc 9

8 Methods

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