1 | <?php |
||
8 | class StrictColumnWidthsParser |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private $columnWidths; |
||
14 | |||
15 | /** |
||
16 | * Initialize the line parser. |
||
17 | * |
||
18 | * @param array $columnWidths The widths of each column in bytes. |
||
19 | */ |
||
20 | public function __construct(array $columnWidths) |
||
24 | |||
25 | /** |
||
26 | * Fetches the data from the line using the column widths to split the data. |
||
27 | * |
||
28 | * The last column's width is ignored and the full width of the line is used. Each column is trimmed of whitespace. |
||
29 | * |
||
30 | * @param string $line The line of data. |
||
31 | * @return array The data by column. |
||
32 | */ |
||
33 | public function getColumns(string $line) : array |
||
47 | } |
||
48 |