Completed
Push — master ( 4a1992...3a4f99 )
by Vladimir
06:33
created

PulseGroup   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Test Coverage

Coverage 64%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
lcom 3
cbo 2
dl 0
loc 75
ccs 16
cts 25
cp 0.64
rs 10
c 1
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getTitle() 0 4 1
A getColor() 0 4 1
A getBoardId() 0 4 1
A __construct() 0 6 1
A isArchived() 0 4 1
A isDeleted() 0 4 1
A deleteGroup() 0 15 2
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\DaPulse;
9
10
use allejo\DaPulse\Exceptions\InvalidObjectException;
11
use allejo\DaPulse\Objects\ApiObject;
12
13
class PulseGroup extends ApiObject
14
{
15
    const API_PREFIX = "boards";
16
17
    protected $pos;
18
    protected $title;
19
    protected $color;
20
    protected $board_id;
21
    protected $archived;
22
    protected $deleted;
23
24
    /**
25
     * PulseGroup constructor.
26
     *
27
     * @internal
28
     *
29
     * @param array $array
30
     */
31 5
    public function __construct ($array)
32
    {
33 5
        $this->arrayConstructionOnly = true;
34
35 5
        parent::__construct($array);
36 5
    }
37
38 1
    public function getId ()
39
    {
40 1
        return $this->id;
41
    }
42
43 2
    public function getTitle ()
44
    {
45 2
        return $this->title;
46
    }
47
48 1
    public function getColor ()
49
    {
50 1
        return $this->color;
51
    }
52
53 2
    public function getBoardId ()
54
    {
55 2
        return $this->board_id;
56
    }
57
58 3
    public function isArchived ()
59
    {
60 3
        return (bool)$this->archived;
61
    }
62
63 1
    public function isDeleted ()
64
    {
65 1
        return (bool)$this->deleted;
66
    }
67
68
    /**
69
     * @throws InvalidObjectException The board ID is nonexistent. This typically occurs when a group has been archived
70
     *                                or deleted and the information is not accessible.
71
     */
72
    public function deleteGroup ()
73
    {
74
        if (!isset($this->board_id))
75
        {
76
            throw new InvalidObjectException("This group may have been archived or deleted; its parent board ID cannot be accessed", 3);
77
        }
78
79
        $this->checkInvalid();
80
81
        $url = sprintf("%s/%s/groups/%s.json", parent::apiEndpoint(), $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 deleteGroup()). 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...
82
83
        self::sendDelete($url);
84
85
        $this->deletedObject = true;
86
    }
87
}