json = $json; $this->data = json_decode($this->json, true); $this->dataJson = json_decode($this->data['data']['data'], true); } public function beginTable(): void { $paramsStr = $this->createParams($this->data['meta']['params']); $hook = $this->beforePrintTable; $this->html = $hook(); $this->html .= ""; } public function createColum(): string { foreach ($this->data['meta']['columns'] as $key => $column){ if ($this->issetColumn($key)){ if ($this->beforePrintCell){ $hook = $this->beforePrintCell; $this->dataJson[$key] = $hook($key, $this->dataJson[$key]); } $this->html .= ""; } } return $this->html; } private function issetColumn($column) { if (isset($this->data['meta']['columns'])){ foreach ($this->data['meta']['columns'] as $key => $currentColumn){ if ($key === $column){ return true; } } } return false; } public function endTable() { $this->html .= "
" . $column . ": " . $this->dataJson[$key] . "
"; $hookAfter = $this->afterPrintTable; $this->html .= $hookAfter(); } public function create() { $this->beginTable(); $this->createColum(); $this->endTable(); } public function beforeTable(\Closure $closure): void { $this->beforePrintTable = $closure; } public function afterTable(\Closure $closure): void { $this->afterPrintTable = $closure; } public function render() { echo $this->html; } public function setBeforePrintCell(\Closure $closure): void { $this->beforePrintCell = $closure; } }