html; } public function setBeforePrintCell(\Closure $closure): void { $this->beforePrintCell = $closure; } public function getCustomCell(string $key, string|null $cell) { if (is_array($this->beforePrintCell)) { if (isset($this->beforePrintCell[$key])) { if (is_array($this->beforePrintCell[$key])){ if (!isset($this->beforePrintCell[$key]['format'])){ $this->beforePrintCell[$key]['format'] = "text"; } $format = explode(":", $this->beforePrintCell[$key]['format']); $formatClass = FormatMapper::getFormat()[$format[0]]; $cell = $formatClass::fetch($cell, $format[1] ?? ""); if (isset($this->beforePrintCell[$key]['value'])){ $hook = $this->beforePrintCell[$key]['value']; $cell = $hook($cell); } } else { $hook = $this->beforePrintCell[$key]; $cell = $hook($cell); } } } else { $hook = $this->beforePrintCell; $cell = $hook($key, $cell); } return $cell; } public function afterPrint(\Closure $closure): void { $this->afterPrintHook = $closure; } public function beforePrint(\Closure $closure): void { $this->beforePrintHook = $closure; } protected function getParamFromCustomColumn(string $column, string $paramName) { if (is_array($this->beforePrintCell)) { if (isset($this->beforePrintCell[$column])) { if (is_array($this->beforePrintCell[$column])){ if (isset($this->beforePrintCell[$column][$paramName])){ return $this->beforePrintCell[$column][$paramName]; } } } } return null; } protected function getStyleFromCustomColumn(string $column) { $styleStr = ''; $style = $this->getParamFromCustomColumn($column, "style"); if (is_array($style)){ foreach ($style as $key => $value){ $styleStr .= $key . ": " . $value . ";"; } } else { $styleStr = $style; } return $styleStr; } }