1 | <?php |
||
21 | class PulseColumn extends ApiObject |
||
22 | { |
||
23 | const API_PREFIX = "boards"; |
||
24 | |||
25 | const Date = "date"; |
||
|
|||
26 | const Numeric = "numeric"; |
||
27 | const Person = "person"; |
||
28 | const Status = "status"; |
||
29 | const Text = "text"; |
||
30 | const Timeline = "timerange"; |
||
31 | |||
32 | protected $title; |
||
33 | protected $type; |
||
34 | protected $empty_text; |
||
35 | protected $labels; |
||
36 | protected $board_id; |
||
37 | |||
38 | private $labelsSanityCheck; |
||
39 | |||
40 | 40 | public function __construct ($idOrArray) |
|
41 | { |
||
42 | 40 | $this->arrayConstructionOnly = true; |
|
43 | 40 | $this->labelsSanityCheck = false; |
|
44 | |||
45 | 40 | parent::__construct($idOrArray); |
|
46 | 40 | } |
|
47 | |||
48 | public function getId () |
||
52 | |||
53 | public function getTitle () |
||
54 | { |
||
55 | $this->lazyLoad(); |
||
56 | |||
57 | return $this->title; |
||
58 | } |
||
59 | |||
60 | 13 | public function getType () |
|
61 | { |
||
62 | 13 | $this->lazyLoad(); |
|
63 | |||
64 | // @todo Workaround due to a bug in DaPulse's API see: https://github.com/allejo/PhpPulse/issues/5 |
||
65 | 13 | if ($this->type === "color") |
|
66 | { |
||
67 | 2 | $this->type = self::Status; |
|
68 | } |
||
69 | |||
70 | 13 | return $this->type; |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * @api |
||
75 | * @todo Remove at 0.4.0 or next breaking release |
||
76 | * @deprecated 0.3.0 This information is only set on the "Last Update" column and therefore shall be removed. This |
||
77 | * value is still available by getting the JSON equivalent of the object if it's needed. |
||
78 | * @since 0.1.0 |
||
79 | * @return string|null |
||
80 | */ |
||
81 | public function getEmptyText () |
||
87 | |||
88 | /** |
||
89 | * Get the labels for a Status column type |
||
90 | * |
||
91 | * @throws InvalidColumnException if the column is not a Status column |
||
92 | * |
||
93 | * @since 0.3.0 An InvalidColumnException is thrown when the given column is not a status column |
||
94 | * @since 0.1.0 |
||
95 | * |
||
96 | * @return string[] |
||
97 | */ |
||
98 | 2 | public function getLabels () |
|
99 | { |
||
100 | 2 | if ($this->getType() != PulseColumn::Status) |
|
101 | { |
||
102 | 1 | throw new InvalidColumnException('This column type does not contain labels'); |
|
103 | } |
||
104 | |||
105 | 1 | $this->lazyLoad(); |
|
106 | 1 | $this->sanitizeLabels(); |
|
107 | |||
108 | 1 | return $this->labels; |
|
109 | } |
||
110 | |||
111 | public function getBoardId () |
||
117 | |||
118 | public function editTitle ($title) |
||
122 | |||
123 | public function editLabels ($labels) |
||
127 | |||
128 | public function deleteColumn () |
||
136 | |||
137 | private function editField ($field, $value) |
||
149 | |||
150 | private function getColumnsUrl () |
||
154 | |||
155 | /** |
||
156 | * DaPulse will only set labels if it has content |
||
157 | */ |
||
158 | 1 | private function sanitizeLabels () |
|
172 | } |