Files
emails/api/common/Implement/Controller/Json.php
2022-11-25 20:52:52 -03:00

16 lines
413 B
PHP

<?php
namespace ProVM\Common\Implement\Controller;
use Psr\Http\Message\ResponseInterface;
trait Json
{
public function withJson(ResponseInterface $response, mixed $data, int $status = 200): ResponseInterface
{
$response->getBody()->write(\Safe\json_encode($data));
return $response
->withStatus($status)
->withHeader('Content-Type', 'application/json');
}
}