Completed
Push — master ( fe4715...d7dc39 )
by Vladimir
02:30
created

Pulse::getGroupId()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 19
rs 8.8571
cc 5
eloc 9
nc 4
nop 1
1
<?php
2
3
/**
4
 * This file contains the Pulse 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\InvalidColumnException;
13
use allejo\DaPulse\Exceptions\InvalidObjectException;
14
use allejo\DaPulse\Exceptions\KeyNotFoundException;
15
use allejo\DaPulse\Objects\ApiObject;
16
use allejo\DaPulse\Objects\PulseColumnStatusValue;
17
use allejo\DaPulse\Objects\PulseColumnDateValue;
18
use allejo\DaPulse\Objects\PulseColumnPersonValue;
19
use allejo\DaPulse\Objects\PulseColumnTextValue;
20
use allejo\DaPulse\Objects\PulseColumnValue;
21
use allejo\DaPulse\Utilities\ArrayUtilities;
22
23
/**
24
 * A class representing a single pulse in a board
25
 *
26
 * @api
27
 * @package allejo\DaPulse
28
 * @since 0.1.0
29
 */
30
class Pulse extends ApiObject
0 ignored issues
show
Coding Style introduced by
The property $updates_count 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 $board_id 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...
Coding Style introduced by
The property $group_id 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 $column_structure 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 $raw_column_values 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 $column_values 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...
31
{
32
    /**
33
     * @ignore
34
     */
35
    const API_PREFIX = "pulses";
36
37
    // ================================================================================================================
38
    //   Instance Variables
39
    // ================================================================================================================
40
41
    /**
42
     * The resource's URL.
43
     *
44
     * @var string
45
     */
46
    protected $url;
47
48
    /**
49
     * The pulse's unique identifier.
50
     *
51
     * @var int
52
     */
53
    protected $id;
54
55
    /**
56
     * The pulse's name.
57
     *
58
     * @var string
59
     */
60
    protected $name;
61
62
    /**
63
     * The board's subscribers.
64
     *
65
     * @var PulseUser[]
66
     */
67
    protected $subscribers;
68
69
    /**
70
     * The amount of updates a pulse has.
71
     *
72
     * @var int
73
     */
74
    protected $updates_count;
75
76
    /**
77
     * The ID of the parent board.
78
     *
79
     * @var int
80
     */
81
    protected $board_id;
82
83
    /**
84
     * Creation time.
85
     *
86
     * @var \DateTime
87
     */
88
    protected $created_at;
89
90
    /**
91
     * Last update time.
92
     *
93
     * @var \DateTime
94
     */
95
    protected $updated_at;
96
97
    /**
98
     * The ID of the group this pulse belongs to
99
     *
100
     * @var string
101
     */
102
    protected $group_id;
103
104
    /**
105
     * @var PulseColumn[]
106
     */
107
    protected $column_structure;
108
109
    /**
110
     * An array containing all of the values a pulse has for each column
111
     *
112
     * @var mixed
113
     */
114
    protected $raw_column_values;
115
116
    /**
117
     * An array containing objects extended from PulseColumnValue storing all of the values for each column
118
     *
119
     * @var array
120
     */
121
    protected $column_values;
122
123
    /**
124
     * The common URL path for retrieving objects relating a pulse such as subscribers, notes, or updates
125
     *
126
     * @var string
127
     */
128
    private $urlSyntax = "%s/%s/%s.json";
129
130
    // ================================================================================================================
131
    //   Getter functions
132
    // ================================================================================================================
133
134
    /**
135
     * The resource's URL.
136
     *
137
     * @return string
138
     */
139
    public function getUrl()
140
    {
141
        return $this->url;
142
    }
143
144
    /**
145
     * The pulse's unique identifier.
146
     *
147
     * @return int
148
     */
149
    public function getId()
150
    {
151
        return $this->id;
152
    }
153
154
    /**
155
     * The pulse's name.
156
     *
157
     * @return string
158
     */
159
    public function getName()
160
    {
161
        return $this->name;
162
    }
163
164
    /**
165
     * The amount of updates a pulse has.
166
     *
167
     * @return int
168
     */
169
    public function getUpdatesCount()
170
    {
171
        return $this->updates_count;
172
    }
173
174
    /**
175
     * The ID of the parent board.
176
     *
177
     * @return int
178
     */
179
    public function getBoardId()
180
    {
181
        return $this->board_id;
182
    }
183
184
    /**
185
     * Creation time.
186
     *
187
     * @return \DateTime
188
     */
189
    public function getCreatedAt()
190
    {
191
        return $this->created_at;
192
    }
193
194
    /**
195
     * Last update time.
196
     *
197
     * @return \DateTime
198
     */
199
    public function getUpdatedAt()
200
    {
201
        return $this->updated_at;
202
    }
203
204
    /**
205
     * Get the ID of the group this Pulse is a part of. If this value is not available, an API call will be made to
206
     * find the group ID via brute force.
207
     *
208
     * **Note** The group ID is cached if it is not available. To update the cached value, use $forceFetch to force an
209
     * API call to get a new value.
210
     *
211
     * **Warning** An API call is always slower than using the cached value.
212
     *
213
     * @param bool $forceFetch Force an API call to get an updated group ID if it has been changed
214
     * @since 0.1.0
215
     * @return string
216
     */
217
    public function getGroupId($forceFetch = false)
218
    {
219
        if (empty($this->group_id) || $forceFetch)
220
        {
221
            $parentBoard = new PulseBoard($this->board_id);
222
            $pulses = $parentBoard->getPulses();
223
224
            foreach ($pulses as $pulse)
225
            {
226
                if ($this->getId() === $pulse->getId())
227
                {
228
                    $this->group_id = $pulse->getGroupId();
229
                    break;
230
                }
231
            }
232
        }
233
234
        return $this->group_id;
235
    }
236
237
    // ================================================================================================================
238
    //   Pulse functions
239
    // ================================================================================================================
240
241
    /**
242
     * Delete the current Pulse
243
     *
244
     * @api
245
     * @throws \allejo\DaPulse\Exceptions\InvalidObjectException
246
     */
247 View Code Duplication
    public function deletePulse ()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
248
    {
249
        $this->checkInvalid();
250
251
        $deleteURL = sprintf("%s/%d.json", self::apiEndpoint(), $this->getId());
252
253
        self::sendDelete($deleteURL);
254
255
        $this->deletedObject = true;
256
    }
257
258
    public function duplicatePulse ($group_id = null, $owner_id = null)
0 ignored issues
show
Coding Style Naming introduced by
The parameter $group_id is not named in camelCase.

This check marks parameter 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 Naming introduced by
The parameter $owner_id is not named in camelCase.

This check marks parameter 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...
259
    {
260
        $url = sprintf("%s/%s/pulses/%s/duplicate.json", parent::apiEndpoint("boards"), $this->getBoardId(), $this->getId());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of duplicatePulse()). 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...
261
        $postParams = array();
262
263
        if ($owner_id instanceof PulseUser)
264
        {
265
            $owner_id = $owner_id->getId();
266
        }
267
268
        self::setIfNotNullOrEmpty($postParams, "group_id", $group_id);
269
        self::setIfNotNullOrEmpty($postParams, "owner_id", $owner_id);
270
271
        $result = self::sendPost($url, $postParams);
272
        $this->pulseInjection($result);
273
274
        return (new Pulse($result['pulse']));
275
    }
276
277 View Code Duplication
    private function pulseInjection (&$result)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
278
    {
279
        $parentBoard = new PulseBoard($this->getBoardId());
280
281
        // Inject some information so a Pulse object can survive on its own
282
        $result["pulse"]["group_id"] = $result["board_meta"]["group_id"];
283
        $result["pulse"]["column_structure"] = $parentBoard->getColumns();
284
        $result["pulse"]["raw_column_values"] = $result["column_values"];
285
    }
286
287
    // ================================================================================================================
288
    //   Column data functions
289
    // ================================================================================================================
290
291
    /**
292
     * Access a pulse's specific column to either access their value or to modify the value.
293
     *
294
     * See the related functions to see the appropriate replacements.
295
     *
296
     * @todo This function only exists for legacy applications. Remove in 0.1.1
0 ignored issues
show
Coding Style introduced by
Comment refers to a TODO task

This check looks TODO comments that have been left in the code.

``TODO``s show that something is left unfinished and should be attended to.

Loading history...
297
     *
298
     * @api
299
     * @deprecated 0.0.1 This function will be removed by 0.1.1. New stricter functions are available
300
     *
301
*@param string $columnId The ID of the column to access. It's typically a slugified version of the column title
302
     *
303
*@see Pulse::getStatusColumn()  getColorColumn()
304
     * @see Pulse::getDateColumn()   getDateColumn()
305
     * @see Pulse::getPersonColumn() getPersonColumn()
306
     * @see Pulse::getTextColumn()   getTextColumn()
307
     * @since 0.1.0
308
     * @throws InvalidObjectException The specified column exists but modification of its value is unsupported either
309
     *                                by this library or the DaPulse API.
310
     * @throws KeyNotFoundException   The specified column ID does not exist for this Pulse
311
     * @return PulseColumnValue The returned object will be a child of this abstract class.
312
     */
313
    public function getColumnValue ($columnId)
314
    {
315
        if (!isset($this->column_values) || !array_key_exists($columnId, $this->column_values))
316
        {
317
            $key = ArrayUtilities::array_search_column($this->raw_column_values, 'cid', $columnId);
318
319
            $data = $this->raw_column_values[$key];
320
            $type = $this->column_structure[$key]->getType();
321
322
            $data['column_id'] = $data['cid'];
323
            $data['board_id'] = $this->getBoardId();
324
            $data['pulse_id'] = $this->getId();
325
326
            $this->column_values[$columnId] = PulseColumnValue::_createColumnType($type, $data);
327
        }
328
329
        return $this->column_values[$columnId];
330
    }
331
332
    /**
333
     * Access a color type column value belonging to this pulse in order to read it or modify.
334
     *
335
     * This function should only be used to access color type values; an exception will be thrown otherwise.
336
     *
337
     * @api
338
     *
339
*@param string $columnId The ID of the column to access. This is typically a slugified version of the column name
340
     *
341
*@since 0.1.0
342
     * @throws InvalidColumnException The specified column is not a "color" type column
343
     * @throws InvalidObjectException The specified column exists but modification of its value is unsupported either
344
     *                                by this library or the DaPulse API.
345
     * @throws KeyNotFoundException   The specified column ID does not exist for this Pulse
346
     * @return PulseColumnStatusValue A column object with access to its contents
347
     */
348
    public function getStatusColumn ($columnId)
349
    {
350
        return $this->getColumn($columnId, PulseColumn::Status);
351
    }
352
353
    /**
354
     * Access a date type column value belonging to this pulse in order to read it or modify.
355
     *
356
     * This function should only be used to access data type values; an exception will be thrown otherwise.
357
     *
358
     * @api
359
     * @param string $columnId The ID of the column to access. This is typically a slugified version of the column name
360
     * @since 0.1.0
361
     * @throws InvalidColumnException The specified column is not a "date" type column
362
     * @throws InvalidObjectException The specified column exists but modification of its value is unsupported either
363
     *                                by this library or the DaPulse API.
364
     * @throws KeyNotFoundException   The specified column ID does not exist for this Pulse
365
     * @return PulseColumnDateValue A column object with access to its contents
366
     */
367
    public function getDateColumn ($columnId)
368
    {
369
        return $this->getColumn($columnId, PulseColumn::Date);
370
    }
371
372
    /**
373
     * Access a person type column value belonging to this pulse in order to read it or modify.
374
     *
375
     * This function should only be used to access person type values; an exception will be thrown otherwise.
376
     *
377
     * @api
378
     * @param string $columnId The ID of the column to access. This is typically a slugified version of the column name
379
     * @since 0.1.0
380
     * @throws InvalidColumnException The specified column is not a "person" type column
381
     * @throws InvalidObjectException The specified column exists but modification of its value is unsupported either
382
     *                                by this library or the DaPulse API.
383
     * @throws KeyNotFoundException   The specified column ID does not exist for this Pulse
384
     * @return PulseColumnPersonValue A column object with access to its contents
385
     */
386
    public function getPersonColumn ($columnId)
387
    {
388
        return $this->getColumn($columnId, PulseColumn::Person);
389
    }
390
391
    /**
392
     * Access a text type column value belonging to this pulse in order to read it or modify.
393
     *
394
     * This function should only be used to access text type values; an exception will be thrown otherwise.
395
     *
396
     * @api
397
     * @param string $columnId The ID of the column to access. This is typically a slugified version of the column name
398
     * @since 0.1.0
399
     * @throws InvalidColumnException The specified column is not a "text" type column
400
     * @throws InvalidObjectException The specified column exists but modification of its value is unsupported either
401
     *                                by this library or the DaPulse API.
402
     * @throws KeyNotFoundException   The specified column ID does not exist for this Pulse
403
     * @return PulseColumnTextValue A column object with access to its contents
404
     */
405
    public function getTextColumn ($columnId)
406
    {
407
        return $this->getColumn($columnId, PulseColumn::Text);
408
    }
409
410
    /**
411
     * Build a pulse's column object if it doesn't exist or return the existing column.
412
     *
413
     * @param string $columnId   The ID of the column to access. This is typically a slugified version of the column
414
     *                           title
415
     * @param string $columnType The type of column being accessed: 'text', 'color', 'person', or 'date'
416
     *
417
     * @since 0.1.0
418
     *
419
     * @throws InvalidColumnException The specified column is not the same type as specified in `$columnType`
420
     * @throws InvalidObjectException The specified column exists but modification of its value is unsupported either
421
     *                                by this library or the DaPulse API.
422
     * @throws KeyNotFoundException   The specified column ID does not exist for this Pulse
423
     *
424
     * @return PulseColumnValue The returned object will be a child of this abstract class.
425
     */
426
    private function getColumn ($columnId, $columnType)
427
    {
428
        if (!isset($this->column_values) || !array_key_exists($columnId, $this->column_values))
429
        {
430
            $key = ArrayUtilities::array_search_column($this->raw_column_values, 'cid', $columnId);
431
432
            $data = $this->raw_column_values[$key];
433
            $type = $this->column_structure[$key]->getType();
434
435
            if ($type !== $columnType)
436
            {
437
                throw new InvalidColumnException("The '$columnId' column was expected to be '$columnType' but was '$type' instead.");
438
            }
439
440
            $data['column_id'] = $data['cid'];
441
            $data['board_id'] = $this->getBoardId();
442
            $data['pulse_id'] = $this->getId();
443
444
            $this->column_values[$columnId] = PulseColumnValue::_createColumnType($type, $data);
445
        }
446
447
        return $this->column_values[$columnId];
448
    }
449
450
    // ================================================================================================================
451
    //   Subscribers functions
452
    // ================================================================================================================
453
454
    /**
455
     * Access a pulse's subscribers
456
     *
457
     * To modify the amount of data returned with pagination, use the following values in the array to configure your
458
     * pagination or offsets.
459
     *
460
     * ```php
461
     * $params = array(
462
     *     "page"     => 1,  // (int) Page offset to fetch
463
     *     "per_page" => 10, // (int) Number of results per page
464
     *     "offset"   => 5,  // (int) Instead of starting at result 0, start counting from result 5
465
     * );
466
     * ```
467
     *
468
     * @api
469
     * @param array $params GET parameters passed to with the query to modify the data returned.
470
     * @since 0.1.0
471
     * @return PulseUser[]
472
     */
473
    public function getSubscribers ($params = array())
474
    {
475
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "subscribers");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getSubscribers()). 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...
476
477
        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 getSubscribers()). 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...
478
    }
479
480
    // ================================================================================================================
481
    //   Notes functions
482
    // ================================================================================================================
483
484
    /**
485
     * Create a new note in this project
486
     *
487
     * @api
488
     * @param  string   $title         The title of the note
489
     * @param  string   $content       The body of the note
490
     * @param  bool     $owners_only   Set to true if only pulse owners can edit this note.
491
     * @param  int|null $user_id       The id of the user to be marked as the note’s last updater
492
     * @param  bool     $create_update Indicates whether to create an update on the pulse notifying subscribers on the
493
     *                                 changes (required user_id to be set).
494
     * @since  0.1.0
495
     * @return PulseNote
496
     */
497
    public function addNote ($title, $content, $owners_only = false, $user_id = NULL, $create_update = false)
0 ignored issues
show
Coding Style Naming introduced by
The parameter $owners_only is not named in camelCase.

This check marks parameter 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 Naming introduced by
The parameter $user_id is not named in camelCase.

This check marks parameter 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 Naming introduced by
The parameter $create_update is not named in camelCase.

This check marks parameter 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...
498
    {
499
        $url        = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "notes");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of addNote()). 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...
500
        $postParams = array(
501
            "id"            => $this->id,
502
            "title"         => $title,
503
            "content"       => $content,
504
            "owners_only"   => $owners_only,
505
            "create_update" => $create_update
506
        );
507
508
        self::setIfNotNullOrEmpty($postParams, "user_id", $user_id);
509
510
        if ($create_update && is_null($user_id))
511
        {
512
            throw new \InvalidArgumentException("The user_id value must be set if an update is to be created");
513
        }
514
515
        $noteResult = self::sendPost($url, $postParams);
516
517
        return (new PulseNote($noteResult));
518
    }
519
520
    /**
521
     * Return all of the notes belonging to this project
522
     *
523
     * @api
524
     * @since  0.1.0
525
     * @return PulseNote[]
526
     */
527
    public function getNotes ()
528
    {
529
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "notes");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getNotes()). 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...
530
531
        return parent::fetchJsonArrayToObjectArray($url, "PulseNote");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getNotes()). 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...
532
    }
533
534
    // ================================================================================================================
535
    //   Updates functions
536
    // ================================================================================================================
537
538
    /**
539
     * Get all of the updates that belong this Pulse
540
     *
541
     * @api
542
     * @since 0.1.0
543
     * @return PulseUpdate[]
544
     */
545
    public function getUpdates ()
546
    {
547
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "updates");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getUpdates()). 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...
548
549
        return parent::fetchJsonArrayToObjectArray($url, "PulseUpdate");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getUpdates()). 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...
550
    }
551
552
    // ================================================================================================================
553
    //   Static functions
554
    // ================================================================================================================
555
556
    /**
557
     * Get all of the pulses that belong to the organization across all boards.
558
     *
559
     * To modify the amount of data returned with pagination, use the following values in the array to configure your
560
     * pagination or offsets.
561
     *
562
     * ```php
563
     * $params = array(
564
     *     "page"     => 1,          // (int) Page offset to fetch
565
     *     "per_page" => 10,         // (int) Number of results per page
566
     *     "offset"   => 5,          // (int) Instead of starting at result 0, start counting from result 5
567
     *     "order_by_latest" => true // (bool) Order the pulses with the most recent first
568
     * );
569
     * ```
570
     *
571
     * @api
572
     * @param array $params GET parameters passed to with the query to modify the data returned.
573
     * @since 0.1.0
574
     * @return Pulse[]
575
     */
576
    public static function getPulses ($params = array())
577
    {
578
        $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 getPulses()). 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...
579
580
        return parent::fetchJsonArrayToObjectArray($url, "Pulse", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getPulses()). 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...
581
    }
582
}