1 | <?php |
||
10 | abstract class Column implements ColumnInterface |
||
11 | { |
||
12 | protected $name; |
||
13 | |||
14 | protected $label; |
||
15 | |||
16 | protected $width = 0; |
||
17 | |||
18 | protected $minWidth = 80; |
||
19 | |||
20 | protected $sortable = false; |
||
21 | |||
22 | protected $fixed = false; |
||
23 | |||
24 | /** |
||
25 | * @var Model |
||
26 | */ |
||
27 | protected $model; |
||
28 | |||
29 | protected $defaultValue = ''; |
||
30 | |||
31 | protected $template = '<span>{{value}}</span>'; |
||
32 | |||
33 | public function __construct($name, $label) |
||
37 | |||
38 | /** |
||
39 | * @return string |
||
40 | */ |
||
41 | public function getName() |
||
45 | |||
46 | /** |
||
47 | * @param string $name |
||
48 | * |
||
49 | * @return Column |
||
50 | */ |
||
51 | public function setName($name) |
||
56 | |||
57 | /** |
||
58 | * @return string |
||
59 | */ |
||
60 | public function getLabel() |
||
64 | |||
65 | /** |
||
66 | * @param string $label |
||
67 | * |
||
68 | * @return Column |
||
69 | */ |
||
70 | public function setLabel(string $label) |
||
75 | |||
76 | /** |
||
77 | * @return int |
||
78 | */ |
||
79 | public function getWidth() |
||
83 | |||
84 | /** |
||
85 | * @param int $width |
||
86 | * |
||
87 | * @return Column |
||
88 | */ |
||
89 | public function setWidth(int $width) |
||
94 | |||
95 | /** |
||
96 | * @return int |
||
97 | */ |
||
98 | public function getMinWidth() |
||
102 | |||
103 | /** |
||
104 | * @param int $minWidth |
||
105 | * |
||
106 | * @return Column |
||
107 | */ |
||
108 | public function setMinWidth(int $minWidth) |
||
113 | |||
114 | public function sortable() |
||
120 | |||
121 | public function customSortable() |
||
129 | |||
130 | public function enableFixed() |
||
136 | |||
137 | public function getModel() |
||
141 | |||
142 | public function setModel(Model $model) |
||
148 | |||
149 | /** |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getTemplate() |
||
156 | |||
157 | /** |
||
158 | * @param string $template |
||
159 | * |
||
160 | * @return Column |
||
161 | */ |
||
162 | public function setTemplate(string $template) |
||
167 | |||
168 | /** |
||
169 | * The column options |
||
170 | * |
||
171 | * @return array |
||
172 | */ |
||
173 | public function toArray() |
||
185 | |||
186 | /** |
||
187 | * Set the column default value |
||
188 | * |
||
189 | * @param mixed $value |
||
190 | * |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setDefaultValue($value) |
||
199 | |||
200 | public function getDefaultValue() |
||
204 | |||
205 | /** |
||
206 | * Get the column value |
||
207 | * |
||
208 | * @return string|static |
||
209 | */ |
||
210 | public function getValue() |
||
218 | |||
219 | protected function getModelValue() |
||
223 | |||
224 | protected function getValueFromObject($instance, $name) |
||
241 | |||
242 | public function jsonSerialize() |
||
246 | |||
247 | public function toJson($options = 0) |
||
251 | |||
252 | public function __toString() |
||
256 | } |
||
257 |
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.