1 | <?php |
||
7 | class Columns extends BasicTerminalObject |
||
8 | { |
||
9 | use StringLength; |
||
10 | |||
11 | /** |
||
12 | * Number of columns |
||
13 | * |
||
14 | * @var integer $column_count |
||
15 | */ |
||
16 | protected $column_count; |
||
17 | |||
18 | /** |
||
19 | * Data to columnize |
||
20 | * |
||
21 | * @var array $data |
||
22 | */ |
||
23 | protected $data; |
||
24 | |||
25 | 32 | public function __construct($data, $column_count = null) |
|
30 | |||
31 | /** |
||
32 | * Calculate the number of columns organize data |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | 32 | public function result() |
|
43 | |||
44 | /** |
||
45 | * Get columns for a regular array |
||
46 | * |
||
47 | * @return array |
||
48 | */ |
||
49 | 28 | protected function columns() |
|
62 | |||
63 | /** |
||
64 | * Re-configure the data into it's final form |
||
65 | */ |
||
66 | 28 | protected function setData() |
|
78 | |||
79 | /** |
||
80 | * Re-configure an array of arrays into column arrays |
||
81 | */ |
||
82 | 8 | protected function setArrayOfArraysData() |
|
96 | |||
97 | /** |
||
98 | * Get columns for an associative array |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | 4 | protected function associativeColumns() |
|
113 | |||
114 | /** |
||
115 | * Get the row of data |
||
116 | * |
||
117 | * @param integer $key |
||
118 | * @param array $column_widths |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | 28 | protected function getRow($key, $column_widths) |
|
134 | |||
135 | /** |
||
136 | * Get the standard column width |
||
137 | * |
||
138 | * @param array $data |
||
139 | * |
||
140 | * @return integer |
||
141 | */ |
||
142 | 32 | protected function getColumnWidth($data) |
|
147 | |||
148 | /** |
||
149 | * Get an array of each column's width |
||
150 | * |
||
151 | * @return array |
||
152 | */ |
||
153 | 28 | protected function getColumnWidths() |
|
167 | |||
168 | /** |
||
169 | * Set the count property |
||
170 | * |
||
171 | * @param integer $column_width |
||
172 | */ |
||
173 | 8 | protected function setColumnCount($column_width) |
|
177 | |||
178 | /** |
||
179 | * Set the count property via an array |
||
180 | * |
||
181 | * @param array $items |
||
182 | */ |
||
183 | protected function setColumnCountViaArray($items) |
||
191 | |||
192 | /** |
||
193 | * Get the number of rows per column |
||
194 | * |
||
195 | * @param integer $column_width |
||
196 | * |
||
197 | * @return integer |
||
198 | */ |
||
199 | 20 | protected function getMaxRows($column_width) |
|
207 | } |
||
208 |