EloquaResourceOwner::getUserName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Permiakov\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
7
class EloquaResourceOwner implements ResourceOwnerInterface
8
{
9
    protected $id;
10
    protected $userName;
11
    protected $displayName;
12
    protected $firstName;
13
    protected $lastName;
14
    protected $emailAddress;
15
    protected $siteName;
16
    protected $compositeId;
17
18
    /**
19
     * @return array
20
     */
21 1
    public function toArray()
22
    {
23
        return array(
24
            'user' => array(
25 1
                'id' => $this->getId(),
26 1
                'username' => $this->getUserName(),
27 1
                'displayName' => $this->getDisplayName(),
28 1
                'firstName' => $this->getFirstName(),
29 1
                'lastName' => $this->getLastName(),
30 1
                'emailAddress' => $this->getEmailAddress()
31 1
            ),
32 1
            'site' => array('name' => $this->getSiteName())
33 1
        );
34
    }
35
36
    /**
37
     * @param $params
38
     * @return $this
39
     */
40 1
    public function exchangeArray($params)
41
    {
42 1
        $user = $params['user'];
43
44 1
        $this->setId(sprintf('%s:%s', $this->getSiteName(), $this->getUserName()));
45 1
        $this->setUserName($user['username']);
46 1
        $this->setDisplayName($user['displayName']);
47 1
        $this->setFirstName($user['firstName']);
48 1
        $this->setLastName($user['lastName']);
49 1
        $this->setEmailAddress($user['emailAddress']);
50 1
        $this->setSiteName($params['site']['name']);
51 1
        return $this;
52
    }
53
54
    /**
55
     * @return mixed
56
     */
57 1
    public function getId()
58
    {
59 1
        return $this->id;
60
    }
61
62
    /**
63
     * @param mixed $id
64
     */
65 1
    public function setId($id)
66
    {
67 1
        $this->id = $id;
68 1
    }
69
70
    /**
71
     * @return mixed
72
     */
73 1
    public function getUserName()
74
    {
75 1
        return $this->userName;
76
    }
77
78
    /**
79
     * @param mixed $userName
80
     */
81 1
    public function setUserName($userName)
82
    {
83 1
        $this->userName = $userName;
84 1
    }
85
86
    /**
87
     * @return mixed
88
     */
89 1
    public function getDisplayName()
90
    {
91 1
        return $this->displayName;
92
    }
93
94
    /**
95
     * @param mixed $displayName
96
     */
97 1
    public function setDisplayName($displayName)
98
    {
99 1
        $this->displayName = $displayName;
100 1
    }
101
102
    /**
103
     * @return mixed
104
     */
105 1
    public function getFirstName()
106
    {
107 1
        return $this->firstName;
108
    }
109
110
    /**
111
     * @param mixed $firstName
112
     */
113 1
    public function setFirstName($firstName)
114
    {
115 1
        $this->firstName = $firstName;
116 1
    }
117
118
    /**
119
     * @return mixed
120
     */
121 1
    public function getLastName()
122
    {
123 1
        return $this->lastName;
124
    }
125
126
    /**
127
     * @param mixed $lastName
128
     */
129 1
    public function setLastName($lastName)
130
    {
131 1
        $this->lastName = $lastName;
132 1
    }
133
134
    /**
135
     * @return mixed
136
     */
137 1
    public function getEmailAddress()
138
    {
139 1
        return $this->emailAddress;
140
    }
141
142
    /**
143
     * @param mixed $emailAddress
144
     */
145 1
    public function setEmailAddress($emailAddress)
146
    {
147 1
        $this->emailAddress = $emailAddress;
148 1
    }
149
150
    /**
151
     * @return mixed
152
     */
153 1
    public function getSiteName()
154
    {
155 1
        return $this->siteName;
156
    }
157
158
    /**
159
     * @param mixed $siteName
160
     * @return EloquaResourceOwner
161
     */
162 1
    public function setSiteName($siteName)
163
    {
164 1
        $this->siteName = $siteName;
165 1
        return $this;
166
    }
167
}
168