MicroFrameWork/kernel/IGTabel/JSONCreator.php
2024-07-31 12:59:06 +03:00

40 lines
881 B
PHP

<?php
namespace kernel\IGTabel;
use app\helpers\Debug;
class JSONCreator
{
protected array $informationArray = [];
public function __construct(array $meta, array $data)
{
$params = empty($meta['params']) ? ["class" => "table table-bordered", "border" => "1"] : $meta['params'];
if ($meta) {
$this->informationArray = [
"meta" => $meta,
"data" => $data ?? []
];
}
}
/**
* @param array $infArr
* @return string|null
*/
protected function toJson(array $infArr): ?string
{
if ($infArr)
return json_encode($infArr, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
return null;
}
/**
* @return string|null
*/
public function getJson(): ?string
{
return $this->toJson($this->informationArray);
}
}