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 | * array of existing data |
||
72 | */ |
||
73 | 42 | 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 | * have its own phpDocs. |
||
83 | * |
||
84 | * @throws ColumnNotFoundException |
||
85 | */ |
||
86 | 21 | public function getValue () |
|
102 | |||
103 | /** |
||
104 | * Create the appropriate object based on the type of column |
||
105 | * |
||
106 | * @internal |
||
107 | * |
||
108 | * @param string $type The type of column as specified by DaPulse's API; i.e. 'text', 'date', 'status', 'person' |
||
109 | * @param array $data An associative array containing data regarding the column |
||
110 | * |
||
111 | * @since 0.1.0 |
||
112 | * |
||
113 | * @todo Fix the hardcoded "color" case statement. See: https://github.com/allejo/PhpPulse/issues/5 |
||
114 | * |
||
115 | * @throws InvalidObjectException |
||
116 | * |
||
117 | * @return PulseColumnStatusValue|PulseColumnDateValue|PulseColumnNumericValue|PulseColumnPersonValue|PulseColumnTagValue|PulseColumnTextValue|PulseColumnTimelineValue |
||
118 | */ |
||
119 | 43 | public static function _createColumnType ($type, $data) |
|
148 | |||
149 | /** |
||
150 | * Check whether to return null because a column's value does not exist. |
||
151 | * |
||
152 | * @return bool True if the column does not have a value |
||
153 | */ |
||
154 | 20 | protected function isNullValue () |
|
158 | |||
159 | 21 | protected function lazyLoad () |
|
182 | |||
183 | /** |
||
184 | * Cast and set the appropriate value for this column |
||
185 | * |
||
186 | * @param $response |
||
187 | */ |
||
188 | abstract protected function setValue ($response); |
||
189 | } |
||
190 |