Skip to content

Add static from method to Response class for flexible response creation.#50

Merged
gustavofreze merged 1 commit intomainfrom
feature/develop
Feb 24, 2026
Merged

Add static from method to Response class for flexible response creation.#50
gustavofreze merged 1 commit intomainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 01:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a generic from method to the Response class that allows creating HTTP responses with any status code, providing more flexibility than the existing status-specific methods (ok, created, accepted, etc.). The new method serves as a factory method for creating responses with custom status codes while maintaining the same API as the specialized methods.

Changes:

  • Added a static from method to the Responses interface and Response class that accepts any Code enum value
  • Implemented comprehensive test coverage using a data provider pattern to test multiple status codes and body types
  • Maintained consistency with existing API design by delegating to InternalResponse::createWithBody

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Responses.php Added interface definition for the from method with proper documentation
src/Response.php Implemented the from method delegating to InternalResponse::createWithBody
tests/ResponseTest.php Added comprehensive test coverage using data provider pattern with 5 test cases covering various status codes and body types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gustavofreze gustavofreze merged commit 9700ecb into main Feb 24, 2026
10 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch February 24, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants