1 | <?php |
||
9 | class ColumnWidths |
||
10 | { |
||
11 | protected $widths; |
||
12 | |||
13 | public function __construct($widths = []) |
||
17 | |||
18 | public function paddingSpace( |
||
25 | |||
26 | /** |
||
27 | * Find all of the columns that are shorter than the specified threshold. |
||
28 | */ |
||
29 | public function findShortColumns($thresholdWidth) |
||
35 | |||
36 | /** |
||
37 | * Find all of the columns that are shorter than the corresponding minimum widths. |
||
38 | */ |
||
39 | public function findUndersizedColumns($minimumWidths) |
||
43 | |||
44 | protected function findColumnsUnderThreshold(array $thresholdWidths) |
||
55 | |||
56 | /** |
||
57 | * If the widths specified by this object do not fit within the |
||
58 | * provided avaiable width, then reduce them all proportionally. |
||
59 | */ |
||
60 | public function adjustMinimumWidths($availableWidth, $dataCellWidths) |
||
90 | |||
91 | /** |
||
92 | * Return proportional weights |
||
93 | */ |
||
94 | public function distribute($availableWidth) |
||
114 | |||
115 | public function lastColumn() |
||
120 | |||
121 | /** |
||
122 | * Return the number of columns. |
||
123 | */ |
||
124 | public function count() |
||
128 | |||
129 | /** |
||
130 | * Calculate how much space is available on average for all columns. |
||
131 | */ |
||
132 | public function averageWidth($availableWidth) |
||
139 | |||
140 | /** |
||
141 | * Return the available keys (column identifiers) from the calculated |
||
142 | * data set. |
||
143 | */ |
||
144 | public function keys() |
||
148 | |||
149 | /** |
||
150 | * Set the length of the specified column. |
||
151 | */ |
||
152 | public function setWidth($key, $width) |
||
156 | |||
157 | /** |
||
158 | * Return the length of the specified column. |
||
159 | */ |
||
160 | public function width($key) |
||
164 | |||
165 | /** |
||
166 | * Return all of the lengths |
||
167 | */ |
||
168 | public function widths() |
||
172 | |||
173 | /** |
||
174 | * Return true if there is no data in this object |
||
175 | */ |
||
176 | public function isEmpty() |
||
180 | |||
181 | /** |
||
182 | * Return the sum of the lengths of the provided widths. |
||
183 | */ |
||
184 | public function totalWidth() |
||
188 | |||
189 | /** |
||
190 | * Return the sum of the lengths of the provided widths. |
||
191 | */ |
||
192 | public static function sumWidth($widths) |
||
201 | |||
202 | /** |
||
203 | * Ensure that every item in $widths that has a corresponding entry |
||
204 | * in $minimumWidths is as least as large as the minimum value held there. |
||
205 | */ |
||
206 | public function enforceMinimums($minimumWidths) |
||
220 | |||
221 | /** |
||
222 | * Remove all of the specified columns from this data structure. |
||
223 | */ |
||
224 | public function removeColumns($columnKeys) |
||
234 | |||
235 | /** |
||
236 | * Select all columns that exist in the provided list of keys. |
||
237 | */ |
||
238 | public function selectColumns($columnKeys) |
||
250 | |||
251 | /** |
||
252 | * Combine this set of widths with another set, and return |
||
253 | * a new set that contains the entries from both. |
||
254 | */ |
||
255 | public function combine(ColumnWidths $combineWith) |
||
264 | } |
||
265 |