Skip to content

feat(attribute): Add HasTarget trait and target() method to manage target attribute for HTML elements.#41

Merged
terabytesoftw merged 1 commit into
mainfrom
feature_16
Jan 30, 2026
Merged

feat(attribute): Add HasTarget trait and target() method to manage target attribute for HTML elements.#41
terabytesoftw merged 1 commit into
mainfrom
feature_16

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Jan 30, 2026

Pull Request

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

Summary by CodeRabbit

  • New Features

    • Added support for managing HTML target attributes with built-in validation for common values (_blank, _parent, _self, _top)
    • Provides immutable API for setting and unsetting target attributes on HTML elements
  • Tests

    • Added comprehensive test suite validating target attribute behavior and validation

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

@terabytesoftw terabytesoftw added the enhancement New feature or request label Jan 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new HasTarget trait to manage the HTML target attribute. It includes a Target enum defining valid target values, an Attribute::TARGET enum case, comprehensive unit tests, and a changelog entry documenting the addition.

Changes

Cohort / File(s) Summary
Core Implementation
src/HasTarget.php, src/Values/Target.php, src/Values/Attribute.php
New HasTarget trait with target() method that validates input against Target enum cases via Validator::oneOf and delegates to addAttribute(). New Target enum with four string-backed cases (BLANK, PARENT, SELF, TOP). New TARGET enum case added to Attribute enum.
Documentation
CHANGELOG.md
Added entry for enhancement #41 documenting the new HasTarget trait and target() method.
Tests
tests/HasTargetTest.php, tests/Support/Provider/TargetProvider.php
New test class validating immutability, empty rendering, attribute setting, and validation error handling. Data provider supplying test cases including enum values and edge cases for comprehensive coverage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A target trait hops into view,
With enum cases shiny and new,
From \_blank to \_self, validated with care,
Immutable attributes float through the air! 🎯✨

🚥 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 concisely summarizes the main change: adding a HasTarget trait and target() method for managing the target attribute. The title is specific, clear, and directly matches the changeset content.

✏️ 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_16

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 terabytesoftw merged commit fda3b6a into main Jan 30, 2026
46 checks passed
@terabytesoftw terabytesoftw deleted the feature_16 branch January 30, 2026 21:16
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