Skip to content

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Dec 15, 2025

Summary

  • Added removeHeader() method to remove specific headers by key
  • Added clearHeaders() method to clear all headers
  • Updated PHP minimum requirement to 8.1
  • Added return type annotation to Exception::__toString()
  • Improved code formatting in Response class

Implementation Details

Both methods follow the fluent interface pattern (return self) for method chaining consistency with existing Client methods. The removeHeader() method uses strtolower() to ensure consistent header key matching with addHeader().

Test Plan

  • Test adding and removing headers
  • Test clearing all headers
  • Verify method chaining works correctly
  • Ensure header key matching is case-insensitive

Summary by CodeRabbit

  • New Features

    • Added header removal methods to allow easier request customization.
  • Bug Fixes

    • Improved JSON response handling with better error detection for invalid data.
  • Chores

    • Raised minimum PHP version requirement to 8.1.
    • Updated development dependencies for code quality tools.

✏️ Tip: You can customize this high-level summary in your review settings.

- Added removeHeader() method to remove specific headers
- Added clearHeaders() method to clear all headers
- Updated PHP requirement to >=8.1
- Added return type annotation to Exception::__toString()
- Improved code formatting in Response class
@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Walkthrough

The pull request updates the project's PHP requirement from 8.0 to 8.1, adds development dependencies for phpstan and laravel/pint, introduces two new header manipulation methods (removeHeader and clearHeaders) to the Client class with method chaining support, adds a return type declaration to the Exception class's __toString() method, and implements runtime validation in the Response class's json() method to throw an exception when JSON decoding yields null. Minor formatting adjustments are made to docblocks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • src/Client.php — Verify that removeHeader() correctly handles case-insensitive key matching and that both new methods properly return $this for fluent chaining
  • src/Response.php — Confirm that the null-check in json() method is the intended behavior and that the exception type thrown is appropriate; review impact of the new fail-fast validation on existing code paths
  • composer.json — Validate that PHP 8.1 requirement is intentional and that all existing code is compatible with the new minimum version

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately reflects the primary change: adding removeHeader and clearHeaders methods to the Client class.
Docstring Coverage ✅ Passed Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-header-management

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a7271a and 67bbc09.

📒 Files selected for processing (4)
  • composer.json (1 hunks)
  • src/Client.php (1 hunks)
  • src/Exception.php (1 hunks)
  • src/Response.php (5 hunks)
🔇 Additional comments (4)
src/Exception.php (1)

15-18: Typed __toString() override looks correct

Declaring __toString(): string is consistent with the parent \Exception signature and the implementation already returns a string, so this is a safe, type‑tightening change.

composer.json (1)

7-13: Confirm dropping PHP 8.0 support and align tooling/CI

Bumping the platform requirement to >=8.1 is a breaking change for any 8.0 consumers. Please confirm this matches the library’s support policy and that CI (and docs/changelog) are updated accordingly.

src/Response.php (1)

50-75: Accessor typing is consistent and safe

getBody(): mixed, getHeaders(): array, and getStatusCode(): int align with the constructor and usage sites; these additions improve static analysis without changing behavior.

src/Client.php (1)

51-72: Header removal/clearing behavior is consistent with existing API

removeHeader() correctly normalizes the key with strtolower() to match addHeader()’s storage convention, and clearHeaders() simply resets the headers array. Returning self keeps these methods consistent with the fluent setters elsewhere in Client. Implementation looks solid.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@abnegate abnegate merged commit c8cd9a5 into main Dec 15, 2025
3 of 4 checks passed
@abnegate abnegate deleted the feat-header-management branch December 15, 2025 05:47
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.

3 participants