Completed
Push — master ( c2a473...712db0 )
by Vladimir
04:22
created

PulseColumn::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
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\Objects\ApiObject;
11
12
/**
13
 * Class PulseColumn
14
 *
15
 * @api
16
 * @package allejo\DaPulse
17
 * @since   0.1.0
18
 */
19
class PulseColumn extends ApiObject
20
{
21
    const API_PREFIX = "boards";
22
23
    const Date     = "date";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected DATE).
Loading history...
24
    const Numeric  = "numeric";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected NUMERIC).
Loading history...
25
    const Person   = "person";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected PERSON).
Loading history...
26
    const Status   = "status";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected STATUS).
Loading history...
27
    const Text     = "text";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected TEXT).
Loading history...
28
    const Timeline = "timerange";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected TIMELINE).
Loading history...
29
30
    protected $title;
31
    protected $type;
32
    protected $empty_text;
33
    protected $labels;
34
    protected $board_id;
35
36 38
    public function __construct ($idOrArray)
37
    {
38 38
        $this->arrayConstructionOnly = true;
39
40 38
        parent::__construct($idOrArray);
41 38
    }
42
43
    public function getId ()
44
    {
45
        return $this->id;
46
    }
47
48
    public function getTitle ()
49
    {
50
        $this->lazyLoad();
51
52
        return $this->title;
53
    }
54
55 11
    public function getType ()
56
    {
57 11
        $this->lazyLoad();
58
59
        // @todo Workaround due to a bug in DaPulse's API see: https://github.com/allejo/PhpPulse/issues/5
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
60 11
        if ($this->type === "color")
61
        {
62 1
            $this->type = self::Status;
63
        }
64
65 11
        return $this->type;
66
    }
67
68
    public function getEmptyText ()
69
    {
70
        $this->lazyLoad();
71
72
        return $this->empty_text;
73
    }
74
75
    public function getLabels ()
76
    {
77
        $this->lazyLoad();
78
79
        return $this->labels;
80
    }
81
82
    public function getBoardId ()
83
    {
84
        $this->lazyLoad();
85
86
        return $this->board_id;
87
    }
88
89
    public function editTitle ($title)
90
    {
91
        $this->editField("title", $title);
92
    }
93
94
    public function editLabels ($labels)
95
    {
96
        $this->editField("labels", $labels);
97
    }
98
99
    public function deleteColumn ()
100
    {
101
        $this->checkInvalid();
102
103
        self::sendDelete($this->getColumnsUrl());
104
105
        $this->deletedObject = true;
106
    }
107
108
    private function editField ($field, $value)
109
    {
110
        $this->checkInvalid();
111
112
        $postParams = [
113
            $field => $value
114
        ];
115
116
        self::sendPut($this->getColumnsUrl(), $postParams);
117
118
        $this->$field = $value;
119
    }
120
121
    private function getColumnsUrl ()
122
    {
123
        return sprintf("%s/%d/columns/%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 getColumnsUrl()). 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...
124
    }
125
}