Completed
Push — master ( 459b9c...bf6d57 )
by Vladimir
02:52
created

PulseUser::getUpdatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file contains the PulseUser class
5
 *
6
 * @copyright 2015 Vladimir Jimenez
7
 * @license   https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT
8
 */
9
10
namespace allejo\DaPulse;
11
12
use allejo\DaPulse\Exceptions\IllegalAccessException;
13
use allejo\DaPulse\Objects\ApiObject;
14
15
/**
16
 * The PulseUser class contains all of the functions related to accessing information about a user
17
 *
18
 * @package allejo\DaPulse
19
 * @since   0.1.0
20
 */
21
class PulseUser extends ApiObject
0 ignored issues
show
Coding Style introduced by
The property $photo_url is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $is_guest is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $created_at is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $updated_at is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    const API_PREFIX = "users";
27
28
    /**
29
     * The resource's URL.
30
     *
31
     * @var string
32
     */
33
    protected $url;
34
35
    /**
36
     * The user's unique identifier.
37
     *
38
     * @var int
39
     */
40
    protected $id;
41
42
    /**
43
     * The user's name.
44
     *
45
     * @var string
46
     */
47
    protected $name;
48
49
    /**
50
     * The user's email.
51
     *
52
     * @var string
53
     */
54
    protected $email;
55
56
    /**
57
     * The user's photo_url.
58
     *
59
     * @var string
60
     */
61
    protected $photo_url;
62
63
    /**
64
     * The user's title.
65
     *
66
     * @var string
67
     */
68
    protected $title;
69
70
    /**
71
     * The user's position.
72
     *
73
     * @var string
74
     */
75
    protected $position;
76
77
    /**
78
     * The user's phone.
79
     *
80
     * @var string
81
     */
82
    protected $phone;
83
84
    /**
85
     * The user's location.
86
     *
87
     * @var string
88
     */
89
    protected $location;
90
91
    /**
92
     * The user's status.
93
     *
94
     * @var string
95
     */
96
    protected $status;
97
98
    /**
99
     * The user's birthday.
100
     *
101
     * @var string
102
     */
103
    protected $birthday;
104
105
    /**
106
     * True if the user is guest, false otherwise
107
     *
108
     * @var bool
109
     */
110
    protected $is_guest;
111
112
    /**
113
     * The user's skills.
114
     *
115
     * @var string[]
116
     */
117
    protected $skills;
118
119
    /**
120
     * Creation time.
121
     *
122
     * @var \DateTime
123
     */
124
    protected $created_at;
125
126
    /**
127
     * Last update time.
128
     *
129
     * @var \DateTime
130
     */
131
    protected $updated_at;
132
133
    /**
134
     * The membership type of this user with respect to a specific Pulse or PulseBoard. This value will not be set if
135
     * a PulseUser object is created standalone and not by another object which supports subscribers or membership.
136
     *
137
     * @var mixed
138
     */
139
    protected $membership;
140
141
    /**
142
     * The URL pattern used for all calls
143
     *
144
     * @var string
145
     */
146
    private $urlSyntax = "%s/%s/%s.json";
147
148
    // ================================================================================================================
149
    //   Getter functions
150
    // ================================================================================================================
151
152
    /**
153
     * The resource's URL.
154
     *
155
     * @return string
156
     */
157
    public function getUrl()
158
    {
159
        return $this->url;
160
    }
161
162
    /**
163
     * The user's unique identifier.
164
     *
165
     * @return int
166
     */
167
    public function getId()
168
    {
169
        return $this->id;
170
    }
171
172
    /**
173
     * The user's name.
174
     *
175
     * @return string
176
     */
177
    public function getName()
178
    {
179
        return $this->name;
180
    }
181
182
    /**
183
     * The user's email.
184
     *
185
     * @return string
186
     */
187
    public function getEmail()
188
    {
189
        return $this->email;
190
    }
191
192
    /**
193
     * The user's photo_url.
194
     *
195
     * @return string
196
     */
197
    public function getPhotoUrl()
198
    {
199
        return $this->photo_url;
200
    }
201
202
    /**
203
     * The user's title.
204
     *
205
     * @return string
206
     */
207
    public function getTitle()
208
    {
209
        return $this->title;
210
    }
211
212
    /**
213
     * The user's position.
214
     *
215
     * @return string
216
     */
217
    public function getPosition()
218
    {
219
        return $this->position;
220
    }
221
222
    /**
223
     * The user's phone.
224
     *
225
     * @return string
226
     */
227
    public function getPhone()
228
    {
229
        return $this->phone;
230
    }
231
232
    /**
233
     * The user's location.
234
     *
235
     * @return string
236
     */
237
    public function getLocation()
238
    {
239
        return $this->location;
240
    }
241
242
    /**
243
     * The user's status.
244
     *
245
     * @return string
246
     */
247
    public function getStatus()
248
    {
249
        return $this->status;
250
    }
251
252
    /**
253
     * The user's birthday.
254
     *
255
     * @return string
256
     */
257
    public function getBirthday()
258
    {
259
        return $this->birthday;
260
    }
261
262
    /**
263
     * True if the user is guest, false otherwise
264
     *
265
     * @return bool
266
     */
267
    public function getIsGuest()
268
    {
269
        return $this->is_guest;
270
    }
271
272
    /**
273
     * The user's skills.
274
     *
275
     * @return string[]
276
     */
277
    public function getSkills()
278
    {
279
        return $this->skills;
280
    }
281
282
    /**
283
     * Creation time.
284
     *
285
     * @return \DateTime
286
     */
287
    public function getCreatedAt()
288
    {
289
        return $this->created_at;
290
    }
291
292
    /**
293
     * Last update time.
294
     *
295
     * @return \DateTime
296
     */
297
    public function getUpdatedAt()
298
    {
299
        return $this->updated_at;
300
    }
301
302
    /**
303
     * Get the membership level of this user with respect to the object that returned or created this instance.
304
     *
305
     * @throws IllegalAccessException This user was not created by an object which supports memberships
306
     *
307
     * @returns string The membership access; e.g. "admin", "subscriber"
308
     */
309
    public function getMembership ()
310
    {
311
        if (isset($this->membership))
312
        {
313
            return $this->membership;
314
        }
315
316
        throw new IllegalAccessException("This value is not accessible which means this user was not created in regards to another object.");
317
    }
318
319
    /**
320
     * Get the user's newsfeed
321
     *
322
     * @param  array $params GET parameters that need to be passed in the URL
323
     *
324
     * @since  0.1.0
325
     *
326
     * @return PulseUpdate[] An array of PulseUpdates that make up the user's newsfeed
327
     */
328
    public function getNewsFeed ($params = array())
329
    {
330
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "newsfeed");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getNewsFeed()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
331
332
        return parent::fetchJsonArrayToObjectArray($url, "PulseUpdate", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getNewsFeed()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
333
    }
334
335
    /**
336
     * Get the user's posts
337
     *
338
     * @param  array $params GET parameters that need to be passed in the URL
339
     *
340
     * @since  0.1.0
341
     *
342
     * @return PulseUpdate[] An array of PulseUpdates for each of the posts
343
     */
344
    public function getPosts ($params = array())
345
    {
346
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "posts");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getPosts()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
347
348
        return parent::fetchJsonArrayToObjectArray($url, "PulseUpdate", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getPosts()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
349
    }
350
351
    /**
352
     * Get the user's unread posts
353
     *
354
     * @param  array $params GET parameters that need to be passed in the URL
355
     *
356
     * @since  0.1.0
357
     *
358
     * @return PulseUpdate[] An array of PulseUpdates for each of the posts
359
     */
360
    public function getUnreadFeed ($params = array())
361
    {
362
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "unread_feed");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getUnreadFeed()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
363
364
        return parent::fetchJsonArrayToObjectArray($url, "PulseUpdate", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getUnreadFeed()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
365
    }
366
367
    /**
368
     * Get all of the users
369
     *
370
     * @param  array $params GET parameters that need to be passed in the URL
371
     *
372
     * @since  0.1.0
373
     *
374
     * @return PulseUser[] An array of PulseUsers for each of the users
375
     */
376
    public static function getUsers ($params = array())
377
    {
378
        $url = sprintf("%s.json", parent::apiEndpoint());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getUsers()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
379
380
        return parent::fetchJsonArrayToObjectArray($url, "PulseUser", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getUsers()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
381
    }
382
}