1 | <?php |
||
10 | class Cell |
||
11 | { |
||
12 | /** |
||
13 | * Numeric cell type (whole numbers, fractional numbers, dates) |
||
14 | */ |
||
15 | const TYPE_NUMERIC = 0; |
||
16 | |||
17 | /** |
||
18 | * String (text) cell type |
||
19 | */ |
||
20 | const TYPE_STRING = 1; |
||
21 | |||
22 | /** |
||
23 | * Formula cell type |
||
24 | * Not used at the moment |
||
25 | */ |
||
26 | const TYPE_FORMULA = 2; |
||
27 | |||
28 | /** |
||
29 | * Empty cell type |
||
30 | */ |
||
31 | const TYPE_EMPTY = 3; |
||
32 | |||
33 | /** |
||
34 | * Boolean cell type |
||
35 | */ |
||
36 | const TYPE_BOOLEAN = 4; |
||
37 | |||
38 | /** |
||
39 | * Date cell type |
||
40 | */ |
||
41 | const TYPE_DATE = 5; |
||
42 | |||
43 | /** |
||
44 | * Error cell type |
||
45 | */ |
||
46 | const TYPE_ERROR = 6; |
||
47 | |||
48 | /** |
||
49 | * The value of this cell |
||
50 | * @var mixed|null |
||
51 | */ |
||
52 | protected $value; |
||
53 | |||
54 | /** |
||
55 | * The cell type |
||
56 | * @var int|null |
||
57 | */ |
||
58 | protected $type; |
||
59 | |||
60 | /** |
||
61 | * @param $value mixed |
||
62 | */ |
||
63 | 92 | public function __construct($value) |
|
67 | |||
68 | /** |
||
69 | * @param mixed|null $value |
||
70 | */ |
||
71 | 92 | public function setValue($value) |
|
76 | |||
77 | /** |
||
78 | * @return mixed|null |
||
79 | */ |
||
80 | 81 | public function getValue() |
|
84 | |||
85 | /** |
||
86 | * @return int|null |
||
87 | */ |
||
88 | public function getType() |
||
92 | |||
93 | /** |
||
94 | * @param int $type |
||
95 | */ |
||
96 | 2 | public function setType($type) |
|
100 | |||
101 | /** |
||
102 | * Get the current value type |
||
103 | * |
||
104 | * @param mixed|null $value |
||
105 | * @return int |
||
106 | */ |
||
107 | 92 | protected function detectType($value) |
|
127 | |||
128 | /** |
||
129 | * @return bool |
||
130 | */ |
||
131 | 1 | public function isBoolean() |
|
135 | |||
136 | /** |
||
137 | * @return bool |
||
138 | */ |
||
139 | 67 | public function isEmpty() |
|
143 | |||
144 | /** |
||
145 | * @return bool |
||
146 | */ |
||
147 | 1 | public function isNumeric() |
|
151 | |||
152 | /** |
||
153 | * @return bool |
||
154 | */ |
||
155 | 1 | public function isString() |
|
159 | |||
160 | /** |
||
161 | * @return bool |
||
162 | */ |
||
163 | 83 | public function isError() |
|
167 | |||
168 | /** |
||
169 | * @return string |
||
170 | */ |
||
171 | public function __toString() |
||
175 | } |
||
176 |