1 | <?php |
||
9 | abstract class Column implements ColumnInterface |
||
10 | { |
||
11 | protected $type; |
||
12 | |||
13 | protected $name; |
||
14 | |||
15 | protected $label; |
||
16 | |||
17 | protected $width = 0; |
||
18 | |||
19 | protected $minWidth = 80; |
||
20 | |||
21 | protected $sortable = false; |
||
22 | |||
23 | protected $fixed = false; |
||
24 | |||
25 | /** |
||
26 | * @var Model |
||
27 | */ |
||
28 | protected $model; |
||
29 | |||
30 | protected $defaultValue = ''; |
||
31 | |||
32 | public function __construct($name, $label) |
||
36 | |||
37 | /** |
||
38 | * @return string |
||
39 | */ |
||
40 | public function getType() |
||
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | public function getName() |
||
52 | |||
53 | /** |
||
54 | * @param string $name |
||
55 | * |
||
56 | * @return Column |
||
57 | */ |
||
58 | public function setName($name) |
||
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getLabel() |
||
72 | |||
73 | /** |
||
74 | * @param string $label |
||
75 | * |
||
76 | * @return Column |
||
77 | */ |
||
78 | public function setLabel(string $label) |
||
84 | |||
85 | /** |
||
86 | * @return int |
||
87 | */ |
||
88 | public function getWidth() |
||
92 | |||
93 | /** |
||
94 | * @param int $width |
||
95 | * |
||
96 | * @return Column |
||
97 | */ |
||
98 | public function setWidth(int $width) |
||
104 | |||
105 | /** |
||
106 | * @return int |
||
107 | */ |
||
108 | public function getMinWidth() |
||
112 | |||
113 | /** |
||
114 | * @param int $minWidth |
||
115 | * |
||
116 | * @return Column |
||
117 | */ |
||
118 | public function setMinWidth(int $minWidth) |
||
124 | |||
125 | public function getSortable() |
||
129 | |||
130 | /** |
||
131 | * @return $this |
||
132 | */ |
||
133 | public function enableSortable() |
||
139 | |||
140 | /** |
||
141 | * |
||
142 | * @return $this |
||
143 | */ |
||
144 | public function customSortable() |
||
150 | |||
151 | public function isFixed() |
||
155 | |||
156 | public function enableFixed() |
||
162 | |||
163 | public function getModel() |
||
167 | |||
168 | public function setModel(Model $model) |
||
174 | |||
175 | /** |
||
176 | * The column options |
||
177 | * |
||
178 | * @return array |
||
179 | */ |
||
180 | public function toArray() |
||
192 | |||
193 | /** |
||
194 | * Set the column default value |
||
195 | * |
||
196 | * @param mixed $value |
||
197 | * |
||
198 | * @return $this |
||
199 | */ |
||
200 | public function setDefaultValue($value) |
||
206 | |||
207 | public function getDefaultValue() |
||
211 | |||
212 | /** |
||
213 | * Get the column value |
||
214 | * |
||
215 | * @return string|static |
||
216 | */ |
||
217 | public function getValue() |
||
226 | |||
227 | protected function getModelValue() |
||
231 | |||
232 | protected function getValueFromObject($instance, $name) |
||
249 | |||
250 | public function jsonSerialize() |
||
254 | |||
255 | public function toJson($options = 0) |
||
259 | |||
260 | public function __toString() |
||
264 | } |
||
265 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.