Files
oficial/app/src/Controller/API/withJson.php

14 lines
340 B
PHP
Raw Normal View History

2023-10-13 10:45:21 -03:00
<?php
namespace Incoviba\Controller\API;
use Psr\Http\Message\ResponseInterface;
trait withJson
{
public function withJson(ResponseInterface $response, array $data = []): ResponseInterface
{
$response->getBody()->write(json_encode($data));
return $response->withHeader('Content-Type', 'application/json');
}
}