14 lines
391 B
PHP
14 lines
391 B
PHP
|
<?php
|
||
|
namespace Incoviba\API\Common\Define\Controller;
|
||
|
|
||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||
|
|
||
|
trait Json {
|
||
|
public function withJson(Response $response, $data, $status = 200): Response {
|
||
|
$response->getBody()->write(json_encode($data, JSON_UNESCAPED_SLASHES));
|
||
|
return $response
|
||
|
->withStatus($status)
|
||
|
->withHeader('content-type', 'application/json');
|
||
|
}
|
||
|
}
|