/** * * @param FileInterface $file * @param array $columnPages [[(ColumnSchema)$columnPage, 'ASC'], [$columnPage2, 'DESC'], $columnPage3, ...] * @throws ErrorException */ public function __construct(FileInterface $file, array $columnPages) { // rebuild array to have usable keys $usedColumnSchemas = array(); foreach ($columnPages as $columnDataset) { if (count($columnDataset) === 2) { list($columnPage, $direction) = $columnDataset; } elseif (count($columnDataset) === 1) { $columnPage = current($columnDataset); $direction = "ASC"; } elseif ($columnDataset instanceof ColumnSchema) { $columnPage = $columnDataset; $direction = "ASC"; } else { throw new ErrorException("Invalid content in parameter \$columnPages!"); } $direction = $direction === "ASC" ? "ASC" : "DESC"; if (!$columnPage instanceof ColumnSchema) { throw new ErrorException("Given column-page is not subclass of 'ColumnSchema'!"); } $usedColumnSchemas[] = [$columnPage, $direction]; } $this->file = $file; $this->columnPages = $usedColumnSchemas; if ($file->getLength() <= 0) { $file->setData(str_pad("", $this->getPageSize(), "")); } }
public function setDoublesFile(FileInterface $file) { $this->doublesFile = $file; if ($file->getLength() <= 0) { $file->setData(str_pad("", $this->keyLength * 2, "")); } }