-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Simplify node insertion logic in beforeInsert()
method of NestedSetsBehavior
class.
#18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… `NestedSetsBehavior` class.
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant NestedSetsBehavior
participant Node
Caller->>NestedSetsBehavior: beforeInsert()
alt $this->operation is valid and $this->node exists
NestedSetsBehavior->>Node: getAttribute('left' or 'right')
NestedSetsBehavior-->>Caller: proceed with insertion logic
else $this->operation unsupported
NestedSetsBehavior-->>Caller: throw NotSupportedException
end
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 phpcs (3.7.2)src/NestedSetsBehavior.php📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings
⏰ Context from checks skipped due to timeout of 90000ms (4)
🔇 Additional comments (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 85 89 +4
===========================================
Files 2 2
Lines 458 468 +10
===========================================
+ Hits 458 468 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the node insertion logic in the NestedSetsBehavior class to simplify condition handling and improve error handling when the target node is absent.
- Replaces separate variable assignments with inline attribute retrieval in a match(true) structure.
- Adds explicit null checks for node-based operations to ensure proper error handling.
Comments suppressed due to low confidence (1)
src/NestedSetsBehavior.php:379
- [nitpick] Add a brief comment explaining why the MAKE_ROOT branch does not perform a null check on $this->node, ensuring clarity about the intended behavior for root node insertions.
$this->operation === self::OPERATION_MAKE_ROOT => $this->beforeInsertRootNode(),
Summary by CodeRabbit