Skip to content

Commit

Permalink
refactor(Response): improve Response class
Browse files Browse the repository at this point in the history
- Refactor the Response class to improve code readability and maintainability
- Add missing PHPDoc comments
- Implement the ArrayAccess interface for easier access to response data
- Update the constructor to accept additional parameters
- Add new methods for retrieving response information such as headers, status code, and body
- Improve error handling and exception throwing
- Update the `getBodyContents` method to use `getBody` and `rewind`
- Update the `toJson` method to use `toArray` and `json_encode`
- Add new methods for saving the response to a file
- Add new methods for handling cookies and transfer stats
- Improve the `__toString` method to use the `body` method
- Update the `createFromPsrResponse` method to return a new instance of the Response class
- Add missing PHPDoc comments to methods
- Update the `toObject` method to use `json_decode`
- Add new methods for checking if the request was successful, if there was a redirect, and if there was a client or server error
- Update the `save` method to use `is_dir`, `mkdir`, and `is_writable` functions
- Update the `toObject` method to return an object
- Add new methods for getting the response cookies and handler stats
- Add new methods for closing the stream and getting the underlying PSR response
- Add new methods for creating an exception and throwing an exception if a server or client error occurred
- Add new methods for throwing an exception if the response status code matches a given code
- Add new methods for throwing an exception unless the response status code matches a given code
- Add new methods for throwing an exception if the response status code is a 4xx or 5xx level code
- Implement the ArrayAccess interface for accessing response data
- Add missing PHPDoc comments to methods
  • Loading branch information
guanguans committed Feb 6, 2024
1 parent 38faad9 commit efca7be
Showing 1 changed file with 337 additions and 43 deletions.
Loading

0 comments on commit efca7be

Please sign in to comment.