Improvements

This commit is contained in:
2025-05-06 08:38:32 -04:00
parent 05131ec50d
commit 04bf0fc622
4 changed files with 24 additions and 2 deletions

View File

@@ -5,13 +5,15 @@ declare(strict_types=1);
namespace Siteworxpro\App\Http;
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Class JsonResponseFactory
*
* A factory class for creating JSON responses.
*/
class JsonResponseFactory
class JsonResponseFactory implements ResponseFactoryInterface
{
/**
* Create a JSON response with the given data and status code.
@@ -31,4 +33,10 @@ class JsonResponseFactory
body: json_encode($data, JSON_THROW_ON_ERROR)
);
}
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
{
return new Response($code)
->withHeader('Content-type', 'application/json');
}
}