Skip to content

feat(attribute): Add HasContent trait and content() method to manage content attribute for HTML elements.#50

Merged
terabytesoftw merged 1 commit into
mainfrom
feature_23
Jan 31, 2026
Merged

feat(attribute): Add HasContent trait and content() method to manage content attribute for HTML elements.#50
terabytesoftw merged 1 commit into
mainfrom
feature_23

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 support for managing HTML content attributes on elements through an immutable interface
    • Accepts multiple value types: strings, Stringable objects, enums, and null for unsetting
    • Follows the framework's immutable API pattern, returning new instances after modifications
    • Enhances flexibility for meta elements and content-driven HTML components

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

…age `content` 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

📝 Walkthrough

Walkthrough

This pull request introduces a new HasContent trait providing an immutable API for managing the HTML content attribute on elements. The trait exposes a public content() method that delegates to addAttribute() and accepts string, Stringable, UnitEnum, or null values. Comprehensive test coverage with data providers is included.

Changes

Cohort / File(s) Summary
HasContent Trait Implementation
src/HasContent.php
New trait with immutable content() method for managing HTML content attributes; delegates to addAttribute(Attribute::CONTENT, $value) and accepts multiple input types.
Test Suite
tests/HasContentTest.php, tests/Support/Provider/ContentProvider.php
Test class with three test methods validating trait behavior: empty attribute sets, immutability, and correct attribute value storage; includes data-driven tests with external provider covering empty strings, null values, special characters, and attribute replacement scenarios.
Documentation
CHANGELOG.md
Changelog entry documenting addition of new HasContent trait and content() method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A content trait hops into place,
Managing HTML with style and grace,
Immutable, clean, and oh-so-neat,
With tests that make the suite complete! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.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 describes the main change: adding a HasContent trait and content() method to manage the content attribute for HTML elements, which is reflected across all modified files.

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

✨ 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 feature_23

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.

@terabytesoftw
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 31, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terabytesoftw terabytesoftw merged commit 242e2ff into main Jan 31, 2026
46 checks passed
@terabytesoftw terabytesoftw deleted the feature_23 branch January 31, 2026 15:26
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