Completed
Push — develop ( a05ff5...d1fb89 )
by Vladimir
03:27
created

PulseColumn   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 12.12%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 12
c 4
b 0
f 0
lcom 1
cbo 1
dl 0
loc 91
ccs 4
cts 33
cp 0.1212
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getTitle() 0 4 1
A getEmptyText() 0 4 1
A getLabels() 0 4 1
A getBoardId() 0 4 1
A editTitle() 0 4 1
A editLabels() 0 4 1
A deleteColumn() 0 8 1
A editField() 0 12 1
A getColumnsUrl() 0 4 1
A getType() 0 10 2
1
<?php
2
3
namespace allejo\DaPulse;
4
5
use allejo\DaPulse\Objects\ApiObject;
6
7
class PulseColumn extends ApiObject
8
{
9
    const API_PREFIX = "boards";
10
11
    const Date     = "date";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected DATE).
Loading history...
12
    const Numeric  = "numeric";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected NUMERIC).
Loading history...
13
    const Person   = "person";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected PERSON).
Loading history...
14
    const Status   = "status";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected STATUS).
Loading history...
15
    const Text     = "text";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected TEXT).
Loading history...
16
    const Timeline = "timerange";
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected TIMELINE).
Loading history...
17
18
    protected $id;
19
    protected $title;
20
    protected $type;
21
    protected $empty_text;
22
    protected $labels;
23
    protected $board_id;
24
25
    public function getId ()
26
    {
27
        return $this->id;
28
    }
29
30
    public function getTitle ()
31
    {
32
        return $this->title;
33
    }
34
35 11
    public function getType ()
36
    {
37
        // @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...
38 11
        if ($this->type === "color")
39
        {
40 1
            $this->type = self::Status;
41
        }
42
43 11
        return $this->type;
44
    }
45
46
    public function getEmptyText ()
47
    {
48
        return $this->empty_text;
49
    }
50
51
    public function getLabels ()
52
    {
53
        return $this->labels;
54
    }
55
56
    public function getBoardId ()
57
    {
58
        return $this->board_id;
59
    }
60
61
    public function editTitle ($title)
62
    {
63
        $this->editField("title", $title);
64
    }
65
66
    public function editLabels ($labels)
67
    {
68
        $this->editField("labels", $labels);
69
    }
70
71
    public function deleteColumn ()
72
    {
73
        $this->checkInvalid();
74
75
        self::sendDelete($this->getColumnsUrl());
76
77
        $this->deletedObject = true;
78
    }
79
80
    private function editField ($field, $value)
81
    {
82
        $this->checkInvalid();
83
84
        $postParams = array(
85
            $field => $value
86
        );
87
88
        self::sendPut($this->getColumnsUrl(), $postParams);
89
90
        $this->$field = $value;
91
    }
92
93
    private function getColumnsUrl ()
94
    {
95
        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...
96
    }
97
}