diff --git a/src/Internal/Response.php b/src/Internal/Response.php index aca7b58..5cc31d0 100644 --- a/src/Internal/Response.php +++ b/src/Internal/Response.php @@ -20,7 +20,9 @@ private function __construct( public static function from(HttpCode $code, mixed $data, array $headers): ResponseInterface { - $headers = empty($headers) ? ['Content-Type' => 'application/json'] : $headers; + if (empty($headers)) { + $headers[] = ['Content-Type' => 'application/json']; + } return new Response(code: $code, body: StreamFactory::from(data: $data), headers: $headers); } diff --git a/tests/HttpResponseTest.php b/tests/HttpResponseTest.php index 5395a3c..dd01ab9 100644 --- a/tests/HttpResponseTest.php +++ b/tests/HttpResponseTest.php @@ -8,7 +8,7 @@ class HttpResponseTest extends TestCase { - private array $defaultHeader = ['Content-Type' => 'application/json']; + private array $defaultHeader = [['Content-Type' => 'application/json']]; /** * @dataProvider providerData