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

14 lines
347 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
{
2023-10-19 20:46:52 -03:00
public function withJson(ResponseInterface $response, array|object $data = []): ResponseInterface
2023-10-13 10:45:21 -03:00
{
$response->getBody()->write(json_encode($data));
return $response->withHeader('Content-Type', 'application/json');
}
}