Passed
Push — master ( 8eea92...da79af )
by Dāvis
03:03
created

TwitterUser   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 106
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
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\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
     * @param  array $response
42
     */
43
    public function __construct(array $response)
44
    {
45
        $this->response = $response;
46
47
        $this->id = intval($this->response['user_id']);
48
49
        if (isset($this->response['email'])) {
50
            $this->email = $this->response['email'];
51
        }
52
53
        $this->username = preg_replace('/[^a-z\d]/i', '', $this->response['screen_name']);
54
    }
55
56
    /**
57
     * Returns all the data obtained about the user.
58
     *
59
     * @return array
60
     */
61
    public function toArray()
62
    {
63
        return $this->response;
64
    }
65
66
    /**
67
     * Get the value of Id
68
     *
69
     * @return integer
70
     */
71
    public function getId()
72
    {
73
        return $this->id;
74
    }
75
76
    /**
77
     * Get the value of Email
78
     *
79
     * @return string
80
     */
81
    public function getEmail()
82
    {
83
        return $this->email;
84
    }
85
86
    /**
87
     * Get the value of First Name
88
     *
89
     * @return string
90
     */
91
    public function getFirstName()
92
    {
93
        return $this->firstName;
94
    }
95
96
    /**
97
     * Get the value of Last Name
98
     *
99
     * @return string
100
     */
101
    public function getLastName()
102
    {
103
        return $this->lastName;
104
    }
105
106
    /**
107
     * Get the value of Username
108
     *
109
     * @return string
110
     */
111
    public function getUsername()
112
    {
113
        return $this->username;
114
    }
115
116
}
117