1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file contains the PulseColumnValue class |
5
|
|
|
* |
6
|
|
|
* @copyright 2015 Vladimir Jimenez |
7
|
|
|
* @license https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace allejo\DaPulse\Objects; |
11
|
|
|
|
12
|
|
|
use allejo\DaPulse\Exceptions\InvalidObjectException; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The base class used for column values belonging to a specified class |
16
|
|
|
* |
17
|
|
|
* @internal |
18
|
|
|
* @package allejo\DaPulse\Objects |
19
|
|
|
* @since 0.1.0 |
20
|
|
|
*/ |
21
|
|
|
abstract class PulseColumnValue extends ApiObject |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
const API_PREFIX = "boards"; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The ID of the parent board that this column's Pulse belongs to. |
27
|
|
|
* |
28
|
|
|
* @var int |
29
|
|
|
*/ |
30
|
|
|
protected $board_id; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The ID of the current column. This is a unique identifier when accessing columns through the API. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
protected $column_id; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The ID of the Pulse this column value belongs to |
41
|
|
|
* |
42
|
|
|
* @var int |
43
|
|
|
*/ |
44
|
|
|
protected $pulse_id; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* The value that this column has. The data type can be an integer, string, or DateTime depending on the column type |
48
|
|
|
* |
49
|
|
|
* @var mixed |
50
|
|
|
*/ |
51
|
|
|
protected $column_value; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* This constructor only accepts an array of the data regarding a specific column |
55
|
|
|
* |
56
|
|
|
* @internal |
57
|
|
|
* |
58
|
|
|
* @param array $array An associative array containing information regarding a column's value |
59
|
|
|
* |
60
|
|
|
* @since 0.1.0 |
61
|
|
|
* |
62
|
|
|
* @throw \InvalidArgumentException An ID is given when an instance of this object can only be created from an array |
63
|
|
|
* of existing data |
64
|
|
|
*/ |
65
|
|
|
public function __construct($array) |
66
|
|
|
{ |
67
|
|
|
$this->arrayConstructionOnly = true; |
68
|
|
|
|
69
|
|
|
parent::__construct($array); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Create the appropriate object based on the type of column |
74
|
|
|
* |
75
|
|
|
* @internal |
76
|
|
|
* |
77
|
|
|
* @param string $type The type of column as specified by DaPulse's API; i.e. 'text', 'date', 'color', 'person' |
78
|
|
|
* @param array $data An associative array containing data regarding the column |
79
|
|
|
* |
80
|
|
|
* @since 0.1.0 |
81
|
|
|
* |
82
|
|
|
* @throws \allejo\DaPulse\Exceptions\InvalidObjectException |
83
|
|
|
* |
84
|
|
|
* @return PulseColumnColorValue|PulseColumnDateValue|PulseColumnPersonValue|PulseColumnTextValue |
85
|
|
|
*/ |
86
|
|
|
public static function _createColumnType ($type, $data) |
87
|
|
|
{ |
88
|
|
|
switch ($type) |
89
|
|
|
{ |
90
|
|
|
case "text": |
91
|
|
|
return (new PulseColumnTextValue($data)); |
92
|
|
|
|
93
|
|
|
case "color": |
94
|
|
|
return (new PulseColumnColorValue($data)); |
95
|
|
|
|
96
|
|
|
case "person": |
97
|
|
|
return (new PulseColumnPersonValue($data)); |
98
|
|
|
|
99
|
|
|
case "date": |
100
|
|
|
return (new PulseColumnDateValue($data)); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
throw new InvalidObjectException("'$type' is an unsupported column type to modify."); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
abstract public function getValue(); |
107
|
|
|
abstract public function updateValue($updateValue); |
108
|
|
|
} |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.