User   A
last analyzed

Complexity

Total Complexity 32

Size/Duplication

Total Lines 309
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 309
ccs 98
cts 98
cp 1
rs 9.6
c 0
b 0
f 0
wmc 32

29 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A isGroupAdmin() 0 3 1
A setId() 0 4 1
A getId() 0 3 1
A getMentionName() 0 3 1
A parseJson() 0 19 3
A getTitle() 0 3 1
A getPhotoUrl() 0 3 1
A setTimezone() 0 4 1
A isGuest() 0 3 1
A setCreated() 0 4 1
A setEmail() 0 4 1
A getTimezone() 0 3 1
A getXmppJid() 0 3 1
A isDeleted() 0 3 1
A getLastActive() 0 3 1
A setName() 0 4 1
A toJson() 0 11 1
A getCreated() 0 3 1
A setLastActive() 0 4 1
A setGuest() 0 4 1
A getEmail() 0 3 1
A setDeleted() 0 4 1
A setPhotoUrl() 0 4 1
A setGroupAdmin() 0 4 1
A setXmppJid() 0 4 1
A setMentionName() 0 4 1
A setTitle() 0 4 1
A getName() 0 3 1
1
<?php
2
3
namespace SolutionDrive\HipchatAPIv2Client\Model;
4
5
class User implements UserInterface
6
{
7
    protected $xmppJid;
8
9
    protected $deleted;
10
11
    protected $name;
12
13
    protected $lastActive;
14
15
    protected $title;
16
17
    protected $links;
18
19
    //protected $presence;
20
21
    protected $created;
22
23
    protected $id;
24
25
    protected $mentionName;
26
27
    protected $groupAdmin;
28
29
    protected $timezone;
30
31
    protected $guest;
32
33
    protected $email;
34
35
    protected $photoUrl;
36
37
    /**
38
     * Builds a user object from server response if json given, otherwise creates an empty object
39
     * Works with partial and full user information.
40
     *
41
     * @param array $json json_decoded response in json given by the server
42
     * 
43
     */
44 24
    public function __construct($json = null)
45
    {
46 24
        if ($json) {
47 4
            $this->parseJson($json);
48
        } else {
49 20
            $this->groupAdmin = false;
50 20
            $this->timezone = 'UTC';
51
        }
52 24
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57 5
    public function parseJson($json)
58
    {
59 5
        $this->mentionName = $json['mention_name'];
60 5
        $this->id = $json['id'];
61 5
        $this->name = $json['name'];
62 5
        if (isset($json['links'])) {
63 4
            $this->links = $json['links'];
64
        }
65 5
        if (isset($json['xmpp_jid'])) {
66 2
            $this->xmppJid = $json['xmpp_jid'];
67 2
            $this->deleted = $json['is_deleted'];
68 2
            $this->lastActive = $json['last_active'];
69 2
            $this->title = $json['title'];
70 2
            $this->created = new \Datetime($json['created']);
71 2
            $this->groupAdmin = $json['is_group_admin'];
72 2
            $this->timezone = $json['timezone'];
73 2
            $this->guest = $json['is_guest'];
74 2
            $this->email = $json['email'];
75 2
            $this->photoUrl = $json['photo_url'];
76
        }
77 5
    }
78
79
    /**
80
     * @inheritdoc
81
     */
82 1
    public function toJson()
83
    {
84 1
        $json = array();
85 1
        $json['name'] = $this->name;
86 1
        $json['title'] = $this->title;
87 1
        $json['mention_name'] = $this->mentionName;
88 1
        $json['is_group_admin'] = $this->groupAdmin;
89 1
        $json['timezone'] = $this->timezone;
90 1
        $json['email'] = $this->email;
91
92 1
        return $json;
93
    }
94
95
    /**
96
     * @inheritdoc
97
     */
98 1
    public function setXmppJid($xmppJid)
99
    {
100 1
        $this->xmppJid = $xmppJid;
101 1
        return $this;
102
    }
103
104
    /**
105
     * @inheritdoc
106
     */
107 1
    public function getXmppJid()
108
    {
109 1
        return $this->xmppJid;
110
    }
111
112
    /**
113
     * @inheritdoc
114
     */
115 1
    public function setDeleted($deleted)
116
    {
117 1
        $this->deleted = $deleted;
118 1
        return $this;
119
    }
120
121
    /**
122
     * @inheritdoc
123
     */
124 1
    public function isDeleted()
125
    {
126 1
        return $this->deleted;
127
    }
128
129
    /**
130
     * @inheritdoc
131
     */
132 2
    public function setName($name)
133
    {
134 2
        $this->name = $name;
135 2
        return $this;
136
    }
137
138
    /**
139
     * @inheritdoc
140
     */
141 1
    public function getName()
142
    {
143 1
        return $this->name;
144
    }
145
146
    /**
147
     * @inheritdoc
148
     */
149 1
    public function setLastActive($lastActive)
150
    {
151 1
        $this->lastActive = $lastActive;
152 1
        return $this;
153
    }
154
155
    /**
156
     * @inheritdoc
157
     */
158 1
    public function getLastActive()
159
    {
160 1
        return $this->lastActive;
161
    }
162
163
    /**
164
     * @inheritdoc
165
     */
166 1
    public function setTitle($title)
167
    {
168 1
        $this->title = $title;
169 1
        return $this;
170
    }
171
172
    /**
173
     * @inheritdoc
174
     */
175 1
    public function getTitle()
176
    {
177 1
        return $this->title;
178
    }
179
180
    /**
181
     * @inheritdoc
182
     */
183 1
    public function setCreated($created)
184
    {
185 1
        $this->created = $created;
186 1
        return $this;
187
    }
188
189
    /**
190
     * @inheritdoc
191
     */
192 1
    public function getCreated()
193
    {
194 1
        return $this->created;
195
    }
196
197
    /**
198
     * @inheritdoc
199
     */
200 3
    public function setId($id)
201
    {
202 3
        $this->id = $id;
203 3
        return $this;
204
    }
205
206
    /**
207
     * @inheritdoc
208
     */
209 3
    public function getId()
210
    {
211 3
        return $this->id;
212
    }
213
214
    /**
215
     * @inheritdoc
216
     */
217 1
    public function setMentionName($mentionName)
218
    {
219 1
        $this->mentionName = $mentionName;
220 1
        return $this;
221
    }
222
223
    /**
224
     * @inheritdoc
225
     */
226 2
    public function getMentionName()
227
    {
228 2
        return $this->mentionName;
229
    }
230
231
    /**
232
     * @inheritdoc
233
     */
234 1
    public function setGroupAdmin($groupAdmin)
235
    {
236 1
        $this->groupAdmin = $groupAdmin;
237 1
        return $this;
238
    }
239
240
    /**
241
     * @inheritdoc
242
     */
243 1
    public function isGroupAdmin()
244
    {
245 1
        return $this->groupAdmin;
246
    }
247
248
    /**
249
     * @inheritdoc
250
     */
251 2
    public function setTimezone($timezone)
252
    {
253 2
        $this->timezone = $timezone;
254 2
        return $this;
255
    }
256
257
    /**
258
     * @inheritdoc
259
     */
260 1
    public function getTimezone()
261
    {
262 1
        return $this->timezone;
263
    }
264
265
    /**
266
     * @inheritdoc
267
     */
268 1
    public function setGuest($guest)
269
    {
270 1
        $this->guest = $guest;
271 1
        return $this;
272
    }
273
274
    /**
275
     * @inheritdoc
276
     */
277 1
    public function isGuest()
278
    {
279 1
        return $this->guest;
280
    }
281
282
    /**
283
     * @inheritdoc
284
     */
285 1
    public function setEmail($email)
286
    {
287 1
        $this->email = $email;
288 1
        return $this;
289
    }
290
291
    /**
292
     * @inheritdoc
293
     */
294 1
    public function getEmail()
295
    {
296 1
        return $this->email;
297
    }
298
299
    /**
300
     * @inheritdoc
301
     */
302 1
    public function setPhotoUrl($photoUrl)
303
    {
304 1
        $this->photoUrl = $photoUrl;
305 1
        return $this;
306
    }
307
308
    /**
309
     * @inheritdoc
310
     */
311 1
    public function getPhotoUrl()
312
    {
313 1
        return $this->photoUrl;
314
    }
315
}
316