public function addSheet(SheetInterface $sheet, $index = null, $insert = false)
{
if (isset($index)) {
if (false === filter_var($index, FILTER_VALIDATE_INT)) {
throw new \InvalidArgumentException("The index must be numeric");
}
if (false === $insert) {
$this->sheetCollection[$index] = $sheet;
return $this;
}
if (true === $insert) {
$array1 = array_slice($this->sheetCollection, 0, $index);
$array1[] = $sheet;
$array2 = array_slice($this->sheetCollection, $index);
$this->sheetCollection = array_merge($array1, $array2);
return $this;
}
}
$this->sheetCollection[] = $sheet;
return $this;
}