Files
kiri-router/src/Format/ArrayFormat.php
T

26 lines
522 B
PHP
Raw Normal View History

2023-10-17 14:50:46 +08:00
<?php
namespace Kiri\Router\Format;
use Kiri\Router\Constrict\Stream;
use Kiri\Router\ContentType;
use Psr\Http\Message\ResponseInterface;
class ArrayFormat implements IFormat
{
/**
* @param $result
* @return ResponseInterface
*/
public function call($result): ResponseInterface
{
$result = json_encode($result);
return \response()->withContentType(ContentType::JSON)
->withBody(new Stream(json_encode($result, JSON_UNESCAPED_UNICODE)));
}
}