Skip to content

feat(attribute): Add HasCharset trait and charset() method to manage charset attribute for HTML elements.#49

Merged
terabytesoftw merged 4 commits into
mainfrom
feature_22
Jan 31, 2026
Merged

feat(attribute): Add HasCharset trait and charset() method to manage charset attribute for HTML elements.#49
terabytesoftw merged 4 commits into
mainfrom
feature_22

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Jan 31, 2026

Pull Request

Q A
Is bugfix?
New feature? ✔️
Breaks BC?

Summary by CodeRabbit

  • New Features
    • Added charset attribute support for HTML elements with extensive encoding options (UTF‑8, ISO‑8859 variants, Windows code pages, Asian encodings, etc.).
  • Tests
    • Added unit tests and a data provider to validate setting, rendering, immutability, and invalid-value handling for charset.
  • Documentation
    • Added changelog entry describing the new charset capability.

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

…age `charset` attribute for HTML elements.
@terabytesoftw terabytesoftw added the enhancement New feature or request label Jan 31, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 31, 2026

Warning

Rate limit exceeded

@terabytesoftw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds support for the HTML charset attribute: a new HasCharset trait with an immutable charset() setter, a Charset string enum listing encodings, an added CHARSET case to the Attribute enum, tests, and a changelog entry.

Changes

Cohort / File(s) Summary
Core Attribute Implementation
src/HasCharset.php, src/Values/Attribute.php, src/Values/Charset.php
Adds HasCharset trait with `public function charset(string
Tests & Data Providers
tests/HasCharsetTest.php, tests/Support/Provider/CharsetProvider.php
Adds unit tests verifying immutability, absence when unset, correct attribute setting/rendering, and invalid-value exception. Provides CharsetProvider data provider combining static cases and enum-derived cases.
Changelog
CHANGELOG.md
Adds entry describing the enhancement: HasCharset trait and charset() method (Enh #49).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐇 I hop through encodings, small and vast,
UTF-8 to ISO, each flag held fast.
HasCharset sewn in with careful art,
Immutable hops from the very start.
✨ A rabbit cheers for charset smart!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly describes the main objective of the pull request: introducing a new HasCharset trait and charset() method for managing the charset attribute in HTML elements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature_22

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/HasCharset.php`:
- Around line 60-65: Add a unit test in HasCharsetTest that verifies
HasCharset::charset rejects invalid values: instantiate an object that uses
HasAttributes and HasCharset, call charset with an invalid value like
'invalid-charset', and assert that an InvalidArgumentException is thrown (this
ensures Validator::oneOf against Charset::cases() is exercised).
🧹 Nitpick comments (1)
src/Values/Charset.php (1)

134-138: Minor formatting inconsistency.

Missing blank line between UTF_32LE and UTF_8 cases, unlike all other cases in this enum.

🔧 Suggested fix
     case UTF_32LE = 'utf-32le';
+
     /**
      * `utf-8` — Unicode UTF-8 encoding (the only valid encoding for HTML5 documents).
      */
     case UTF_8 = 'utf-8';

Comment thread src/HasCharset.php
@terabytesoftw terabytesoftw merged commit ef7ca1f into main Jan 31, 2026
46 checks passed
@terabytesoftw terabytesoftw deleted the feature_22 branch January 31, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant