1 | <?php |
||
22 | abstract class PulseColumnValue extends ApiObject |
||
23 | { |
||
24 | const API_PREFIX = "boards"; |
||
25 | |||
26 | /** |
||
27 | * The default return value for getValue() |
||
28 | * |
||
29 | * @internal |
||
30 | */ |
||
31 | const DEFAULT_VALUE = null; |
||
32 | |||
33 | /** |
||
34 | * The ID of the parent board that this column's Pulse belongs to. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $board_id; |
||
39 | |||
40 | /** |
||
41 | * The ID of the current column. This is a unique identifier when accessing columns through the API. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $column_id; |
||
46 | |||
47 | /** |
||
48 | * The ID of the Pulse this column value belongs to |
||
49 | * |
||
50 | * @var int |
||
51 | */ |
||
52 | protected $pulse_id; |
||
53 | |||
54 | /** |
||
55 | * The value that this column has. The data type can be an integer, string, or DateTime depending on the column type |
||
56 | * |
||
57 | * @var mixed |
||
58 | */ |
||
59 | protected $column_value; |
||
60 | |||
61 | /** |
||
62 | * This constructor only accepts an array of the data regarding a specific column |
||
63 | * |
||
64 | * @internal |
||
65 | * |
||
66 | * @param array $array An associative array containing information regarding a column's value |
||
67 | * |
||
68 | * @since 0.1.0 |
||
69 | * |
||
70 | * @throws \InvalidArgumentException An ID is given when an instance of this object can only be created from an |
||
71 | 38 | * array of existing data |
|
72 | */ |
||
73 | 38 | public function __construct ($array) |
|
79 | |||
80 | /** |
||
81 | * This function must be overloaded by child classes solely calling this function to allow each implementation to |
||
82 | 17 | * have its own phpDocs. |
|
83 | */ |
||
84 | 17 | public function getValue () |
|
100 | |||
101 | /** |
||
102 | * Create the appropriate object based on the type of column |
||
103 | * |
||
104 | * @internal |
||
105 | * |
||
106 | * @param string $type The type of column as specified by DaPulse's API; i.e. 'text', 'date', 'status', 'person' |
||
107 | * @param array $data An associative array containing data regarding the column |
||
108 | * |
||
109 | * @since 0.1.0 |
||
110 | * |
||
111 | * @todo Fix the hardcoded "color" case statement. See: https://github.com/allejo/PhpPulse/issues/5 |
||
|
|||
112 | * |
||
113 | 39 | * @throws InvalidObjectException |
|
114 | * |
||
115 | * @return PulseColumnStatusValue|PulseColumnDateValue|PulseColumnNumericValue|PulseColumnPersonValue|PulseColumnTextValue|PulseColumnTimelineValue |
||
116 | */ |
||
117 | 39 | public static function _createColumnType ($type, $data) |
|
143 | |||
144 | /** |
||
145 | 17 | * Check whether to return null because a column's value does not exist. |
|
146 | * |
||
147 | 17 | * @return bool True if the column does not have a value |
|
148 | */ |
||
149 | protected function isNullValue () |
||
153 | |||
154 | protected function lazyLoad () |
||
177 | |||
178 | /** |
||
179 | * Cast and set the appropriate value for this column |
||
180 | * |
||
181 | * @param $response |
||
182 | */ |
||
183 | abstract protected function setValue ($response); |
||
184 | } |
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.