14 lines
340 B
PHP
14 lines
340 B
PHP
|
<?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');
|
||
|
}
|
||
|
}
|