feat: FakeTemplate -> JsonView

This commit is contained in:
origami11@yandex.ru 2025-12-03 17:12:40 +03:00
parent 18cc1cad01
commit 5170ed8ed5
2 changed files with 12 additions and 4 deletions

40
src/View/JsonView.php Normal file
View file

@ -0,0 +1,40 @@
<?php
namespace ctiso\View;
class JsonView extends \stdClass {
/** @var array */
public $_data = [];
/** @var string */
public $_name = '';
/**
* @param string $name
*/
function __construct($name) {
$this->_name = $name;
}
/**
* @param string $key
* @param mixed $value
*/
function set($key, $value): void {
$this->_data[$key] = $value;
}
/**
* @param string $key
* @param mixed $value
*/
function __set($key, $value): void {
$this->_data[$key] = $value;
}
/**
* @return string
*/
function execute() {
return json_encode($this->_data) ?: '';
}
}