26 lines
522 B
PHP
26 lines
522 B
PHP
|
|
<?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)));
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|