Skip to content

Commit 72c2597

Browse files
committed
Refactoring
1 parent 0162cb0 commit 72c2597

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/JsonResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
* This class MUST be used when returning JSON payloads over HTTP responses.
2525
* It automatically sets the 'Content-Type' header to 'application/json' with the specified charset.
2626
*
27-
* @method JsonStreamInterface getBody() Retrieves the response body as a JSON stream.
27+
* @method PayloadStreamInterface getBody() Retrieves the response body as a JSON stream.
2828
*/
29-
final class JsonResponse extends Response implements JsonResponseInterface
29+
final class JsonResponse extends Response implements PayloadResponseInterface
3030
{
3131
/**
3232
* Constructs a new JsonResponse instance with an optional payload and charset.

src/JsonStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
* @package FastForward\Http\Message
3131
*/
32-
final class JsonStream extends Stream implements JsonStreamInterface
32+
final class JsonStream extends Stream implements PayloadStreamInterface
3333
{
3434
/**
3535
* JSON encoding flags to be applied by default.

src/JsonResponseInterface.php renamed to src/PayloadResponseInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
use Psr\Http\Message\ResponseInterface;
1919

2020
/**
21-
* Interface JsonResponseInterface.
21+
* Interface PayloadResponseInterface.
2222
*
23-
* Defines the contract for JSON-specific HTTP response implementations.
24-
* Implementations of this interface MUST provide access to a JSON payload and comply with PSR-7 ResponseInterface.
23+
* Defines the contract for payload-specific HTTP response implementations.
24+
* Implementations of this interface MUST provide access to a payload and comply with PSR-7 ResponseInterface.
2525
*
26-
* This interface SHALL be used to identify responses intended to transmit JSON-encoded payloads with proper headers.
26+
* This interface SHALL be used to identify responses intended to transmit payloads with proper headers.
2727
*/
28-
interface JsonResponseInterface extends ResponseInterface, PayloadAwareInterface, PayloadImmutableInterface {}
28+
interface PayloadResponseInterface extends PayloadAwareInterface, PayloadImmutableInterface, ResponseInterface {}

src/JsonStreamInterface.php renamed to src/PayloadStreamInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
use Psr\Http\Message\StreamInterface;
1919

2020
/**
21-
* Interface JsonStreamInterface.
21+
* Interface PayloadStreamInterface.
2222
*
23-
* Extends the PSR-7 StreamInterface to provide additional functionality for JSON payload handling.
24-
* Implementations of this interface MUST support both standard stream operations and structured JSON payload manipulation.
23+
* Extends the PSR-7 StreamInterface to provide additional functionality for payload handling.
24+
* Implementations of this interface MUST support both standard stream operations and structured payload manipulation.
2525
*
2626
* @package FastForward\Http\Message
2727
*/
28-
interface JsonStreamInterface extends StreamInterface, PayloadAwareInterface, PayloadImmutableInterface {}
28+
interface PayloadStreamInterface extends PayloadAwareInterface, PayloadImmutableInterface, StreamInterface {}

tests/JsonResponseTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
namespace FastForward\Http\Message\Tests;
1717

1818
use FastForward\Http\Message\JsonResponse;
19-
use FastForward\Http\Message\JsonResponseInterface;
2019
use FastForward\Http\Message\JsonStream;
21-
use FastForward\Http\Message\JsonStreamInterface;
20+
use FastForward\Http\Message\PayloadResponseInterface;
21+
use FastForward\Http\Message\PayloadStreamInterface;
2222
use PHPUnit\Framework\Attributes\CoversClass;
2323
use PHPUnit\Framework\Attributes\UsesClass;
2424
use PHPUnit\Framework\TestCase;
@@ -32,7 +32,7 @@ final class JsonResponseTest extends TestCase
3232
{
3333
public function testClassImplementsJsonResponseInterface(): void
3434
{
35-
self::assertInstanceOf(JsonResponseInterface::class, new JsonResponse());
35+
self::assertInstanceOf(PayloadResponseInterface::class, new JsonResponse());
3636
}
3737

3838
public function testConstructorWillInitializeWithPayload(): void
@@ -42,7 +42,7 @@ public function testConstructorWillInitializeWithPayload(): void
4242
$response = new JsonResponse($payload);
4343

4444
self::assertSame(['success' => true], $response->getPayload());
45-
self::assertInstanceOf(JsonStreamInterface::class, $response->getBody());
45+
self::assertInstanceOf(PayloadStreamInterface::class, $response->getBody());
4646
self::assertSame('application/json; charset=utf-8', $response->getHeaderLine('Content-Type'));
4747
}
4848

0 commit comments

Comments
 (0)