-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add NestedSetsUpdateManager
, QueryConditionBuilder
, and UpdateExpressionBuilder
for centralized database operations; refactor NestedSetsBehavior
to utilize new managers and improve code maintainability.
#47
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
…dateExpressionBuilder` for centralized database operations; refactor `NestedSetsBehavior` to utilize new managers and improve code maintainability.
WalkthroughThe changes refactor nested set tree update logic by introducing a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant NestedSetsBehavior
participant NestedSetsUpdateManager
participant QueryConditionBuilder
participant UpdateExpressionBuilder
participant DB
Client->>NestedSetsBehavior: perform tree operation (insert, move, delete)
NestedSetsBehavior->>NestedSetsUpdateManager: delegate operation (e.g. updateSubtreeForDeletion)
NestedSetsUpdateManager->>QueryConditionBuilder: build query conditions
NestedSetsUpdateManager->>UpdateExpressionBuilder: build update expressions
NestedSetsUpdateManager->>DB: execute updateAll with conditions and expressions
Possibly related PRs
Suggested labels
Poem
✨ 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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #47 +/- ##
=============================================
- Coverage 100.00% 94.20% -5.80%
- Complexity 102 135 +33
=============================================
Files 3 6 +3
Lines 504 587 +83
=============================================
+ Hits 504 553 +49
- Misses 0 34 +34 ☔ 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.
Actionable comments posted: 6
🧹 Nitpick comments (2)
src/NestedSetsBehavior.php (1)
1389-1405
: Consider aligning parameter order for clarity.The parameter order differs between the method signature and the delegation call, which could cause confusion during maintenance.
private function moveSubtreeToTargetTree( - mixed $targetNodeTreeValue, - mixed $currentOwnerTreeValue, - int $depth, int $leftValue, + int $rightValue, int $positionOffset, - int $rightValue, + int $depth, + mixed $currentOwnerTreeValue, + mixed $targetNodeTreeValue, ): void { $this->getUpdateManager()->moveSubtreeToTargetTree( $leftValue, $rightValue, $positionOffset, $depth, $currentOwnerTreeValue, $targetNodeTreeValue, ); }src/NestedSetsUpdateManager.php (1)
252-252
: Fix formatting: remove extra space.- return $this->leftValue; + return $this->leftValue;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/NestedSetsBehavior.php
(9 hunks)src/NestedSetsUpdateManager.php
(1 hunks)src/QueryConditionBuilder.php
(1 hunks)src/UpdateExpressionBuilder.php
(1 hunks)tests/NestedSetsBehaviorTest.php
(0 hunks)tests/support/stub/ExtendableNestedSetsBehavior.php
(0 hunks)
💤 Files with no reviewable changes (2)
- tests/support/stub/ExtendableNestedSetsBehavior.php
- tests/NestedSetsBehaviorTest.php
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: terabytesoftw
PR: yii2-extensions/nested-sets-behavior#13
File: src/NestedSetsBehavior.php:145-145
Timestamp: 2025-06-29T11:22:41.839Z
Learning: The user terabytesoftw prefers to keep PRs focused and small, implementing enhancements in separate dedicated PRs rather than bundling multiple changes together.
🧬 Code Graph Analysis (2)
src/NestedSetsUpdateManager.php (4)
src/QueryConditionBuilder.php (5)
QueryConditionBuilder
(26-163)__construct
(28-32)createCrossTreeCondition
(159-162)createSubtreeCondition
(127-130)createMovementCondition
(143-146)src/UpdateExpressionBuilder.php (6)
UpdateExpressionBuilder
(30-137)__construct
(32-38)createSingleAttributeUpdate
(119-124)createSubtreeMovementAttributes
(93-109)createDepthUpdateAttributes
(77-82)createOffsetExpression
(48-53)src/NestedSetsBehavior.php (3)
moveSubtreeToTargetTree
(1389-1405)NestedSetsBehavior
(47-1423)getTreeValue
(1363-1368)tests/NestedSetsBehaviorTest.php (1)
primaryKey
(1582-1585)
src/QueryConditionBuilder.php (2)
src/UpdateExpressionBuilder.php (1)
__construct
(32-38)src/NestedSetsUpdateManager.php (1)
__construct
(65-85)
🪛 GitHub Check: codecov/patch
src/UpdateExpressionBuilder.php
[warning] 62-62: src/UpdateExpressionBuilder.php#L62
Added line #L62 was not covered by tests
[warning] 64-67: src/UpdateExpressionBuilder.php#L64-L67
Added lines #L64 - L67 were not covered by tests
[warning] 77-77: src/UpdateExpressionBuilder.php#L77
Added line #L77 was not covered by tests
[warning] 79-81: src/UpdateExpressionBuilder.php#L79-L81
Added lines #L79 - L81 were not covered by tests
[warning] 133-133: src/UpdateExpressionBuilder.php#L133
Added line #L133 was not covered by tests
[warning] 135-135: src/UpdateExpressionBuilder.php#L135
Added line #L135 was not covered by tests
src/NestedSetsUpdateManager.php
[warning] 136-136: src/NestedSetsUpdateManager.php#L136
Added line #L136 was not covered by tests
[warning] 138-141: src/NestedSetsUpdateManager.php#L138-L141
Added lines #L138 - L141 were not covered by tests
[warning] 152-152: src/NestedSetsUpdateManager.php#L152
Added line #L152 was not covered by tests
[warning] 154-157: src/NestedSetsUpdateManager.php#L154-L157
Added lines #L154 - L157 were not covered by tests
[warning] 169-169: src/NestedSetsUpdateManager.php#L169
Added line #L169 was not covered by tests
[warning] 176-176: src/NestedSetsUpdateManager.php#L176
Added line #L176 was not covered by tests
[warning] 178-182: src/NestedSetsUpdateManager.php#L178-L182
Added lines #L178 - L182 were not covered by tests
src/QueryConditionBuilder.php
[warning] 82-82: src/QueryConditionBuilder.php#L82
Added line #L82 was not covered by tests
[warning] 84-88: src/QueryConditionBuilder.php#L84-L88
Added lines #L84 - L88 were not covered by tests
[warning] 143-143: src/QueryConditionBuilder.php#L143
Added line #L143 was not covered by tests
[warning] 145-145: src/QueryConditionBuilder.php#L145
Added line #L145 was not covered by tests
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: phpunit-compatibility / PHP 8.3-ubuntu-latest
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
🔇 Additional comments (4)
src/UpdateExpressionBuilder.php (2)
30-38
: LGTM! Well-structured constructor with immutable properties.The use of readonly properties and proper type declarations ensures immutability and type safety.
48-53
: Good implementation of SQL expression building.The use of
sprintf('%+d', $offset)
ensures the sign is always included, and column names are properly quoted for SQL safety.src/NestedSetsBehavior.php (2)
133-142
: Good encapsulation of update operations.The private property with proper PHPDoc and generic typing ensures type safety while maintaining encapsulation.
1412-1422
: Well-implemented lazy initialization pattern.The use of null coalescing assignment operator (
??=
) provides clean and efficient lazy initialization.
public function createShiftUpdateAttributes(int $offset): array | ||
{ | ||
return [ | ||
$this->leftAttribute => $this->createOffsetExpression($this->leftAttribute, $offset), | ||
$this->rightAttribute => $this->createOffsetExpression($this->rightAttribute, $offset), | ||
]; | ||
} |
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.
💡 Verification agent
❓ Verification inconclusive
Add test coverage for boundary shift operations.
This method is critical for nested set integrity but lacks test coverage according to static analysis.
🏁 Script executed:
#!/bin/bash
# Check if there are any tests that might indirectly cover this method
rg -A 5 "createShiftUpdateAttributes|shiftLeftRightAttribute" tests/
Length of output: 70
Add unit tests for UpdateExpressionBuilder::createShiftUpdateAttributes
The createShiftUpdateAttributes method calculates boundary shifts for nested sets but isn’t covered by any existing tests. Please add focused unit tests to verify that, for a given offset, both left and right attributes produce the correct offset expressions.
Locations to address:
- src/UpdateExpressionBuilder.php → createShiftUpdateAttributes
- New or existing test file (e.g. tests/UpdateExpressionBuilderTest.php)
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 62-62: src/UpdateExpressionBuilder.php#L62
Added line #L62 was not covered by tests
[warning] 64-67: src/UpdateExpressionBuilder.php#L64-L67
Added lines #L64 - L67 were not covered by tests
🤖 Prompt for AI Agents
In src/UpdateExpressionBuilder.php around lines 62 to 68, the
createShiftUpdateAttributes method lacks unit test coverage. Add unit tests in a
new or existing test file such as tests/UpdateExpressionBuilderTest.php that
call createShiftUpdateAttributes with various offset values and assert that the
returned array correctly maps left and right attributes to their expected offset
expressions. Ensure tests cover typical and edge cases to verify correct
behavior.
public function createLteCondition(string $attribute, int $value): array | ||
{ | ||
return [ | ||
'<=', | ||
$attribute, | ||
$value, | ||
]; | ||
} |
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.
Add test coverage for less-than-or-equal condition builder.
This basic condition builder lacks test coverage but is likely used in nested set operations.
Would you like me to generate unit tests for the condition builder methods?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 82-82: src/QueryConditionBuilder.php#L82
Added line #L82 was not covered by tests
[warning] 84-88: src/QueryConditionBuilder.php#L84-L88
Added lines #L84 - L88 were not covered by tests
🤖 Prompt for AI Agents
In src/QueryConditionBuilder.php around lines 82 to 89, the createLteCondition
method lacks test coverage. Add unit tests that verify the method returns the
correct array structure for less-than-or-equal conditions, ensuring it handles
various attribute names and integer values correctly. This will improve
reliability and maintainability of nested set operations using this condition
builder.
$primaryKey = $this->owner::primaryKey(); | ||
|
||
if (isset($primaryKey[0]) === false) { | ||
throw new Exception('"' . $this->modelClass . '" must have a primary key.'); | ||
} |
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.
💡 Verification agent
❓ Verification inconclusive
Good error handling for missing primary key.
The check for primary key existence is crucial for data integrity. Consider verifying this scenario is tested.
🏁 Script executed:
#!/bin/bash
# Check if there are tests for models without primary keys
rg -B 5 -A 5 "primaryKey.*return \[\]|without.*primary.*key" tests/
Length of output: 69
Missing test for missing primary key scenario
There are currently no automated tests covering the case when a model has no primary key and updateTreeAttributeForRoot()
throws its exception. Please add a unit test to simulate a model whose primaryKey()
returns an empty array and assert that the following exception is raised:
- File: src/NestedSetsUpdateManager.php (lines 229–233)
if (isset($primaryKey[0]) === false) { throw new Exception('"' . $this->modelClass . '" must have a primary key.'); }
This will ensure the error‐handling path is validated.
🤖 Prompt for AI Agents
In src/NestedSetsUpdateManager.php around lines 229 to 233, add a unit test that
mocks or simulates a model whose primaryKey() method returns an empty array. The
test should call updateTreeAttributeForRoot() and assert that it throws the
expected Exception with the message indicating the model must have a primary
key. This will cover the error-handling path when no primary key is defined.
src/NestedSetsUpdateManager.php
Outdated
public function moveSameTreeNode( | ||
int $leftValue, | ||
int $rightValue, | ||
int $depthOffset, | ||
int $positionOffset, | ||
mixed $treeValue, | ||
): void { | ||
$this->updateDepthInRange($leftValue, $rightValue, $depthOffset, $treeValue); | ||
|
||
foreach ([$this->leftAttribute, $this->rightAttribute] as $attribute) { | ||
$this->modelClass::updateAll( | ||
$this->expressionBuilder->createSingleAttributeUpdate($attribute, $positionOffset), | ||
$this->conditionBuilder->createMovementCondition($leftValue, $rightValue, $treeValue), | ||
); | ||
} | ||
} |
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.
💡 Verification agent
❓ Verification inconclusive
Add test coverage for same-tree node movement.
The moveSameTreeNode()
method handles critical nested set operations but lacks test coverage.
🏁 Script executed:
#!/bin/bash
# Check for any tests that might cover node movement operations
rg -A 10 "moveSameTreeNode|moveNode.*same.*tree" tests/
Length of output: 57
Missing test coverage for moveSameTreeNode()
A search through the tests/ directory did not reveal any existing unit tests covering the moveSameTreeNode()
method in src/NestedSetsUpdateManager.php (lines 169–184). This method drives critical nested-set logic and needs its behavior verified.
Please add tests that cover, at minimum:
- Moving a node within the same tree
- Correct calls to
updateDepthInRange()
- Correct attribute updates via the two
updateAll()
invocations
Suggested location:
• tests/NestedSetsUpdateManagerTest.php
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 169-169: src/NestedSetsUpdateManager.php#L169
Added line #L169 was not covered by tests
[warning] 176-176: src/NestedSetsUpdateManager.php#L176
Added line #L176 was not covered by tests
[warning] 178-182: src/NestedSetsUpdateManager.php#L178-L182
Added lines #L178 - L182 were not covered by tests
🤖 Prompt for AI Agents
In src/NestedSetsUpdateManager.php lines 169 to 184, the moveSameTreeNode()
method lacks unit test coverage. Add tests in
tests/NestedSetsUpdateManagerTest.php that verify moving a node within the same
tree, ensure updateDepthInRange() is called with correct parameters, and confirm
that updateAll() is invoked twice with the expected attribute updates and
conditions.
…stedSetsUpdateManager` and remove redundant method in `QueryConditionBuilder`.
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.
Actionable comments posted: 1
♻️ Duplicate comments (3)
src/QueryConditionBuilder.php (1)
82-89
: Address the missing test coverage for less-than-or-equal condition builder.This method lacks test coverage as indicated by the static analysis and previous review comments. The implementation is correct, but testing is essential for reliability.
Would you like me to generate unit tests for the
createLteCondition
method?src/NestedSetsUpdateManager.php (2)
229-233
: Missing test coverage for primary key validation.The error handling for missing primary key scenarios lacks test coverage as noted in previous reviews. This is critical validation logic that should be tested.
Please add a unit test that mocks a model with an empty
primaryKey()
return value and verifies the exception is thrown correctly.
169-184
: Missing test coverage for same-tree node movement.The
moveSameTreeNode()
method handles critical nested set operations but lacks test coverage as noted in previous reviews.Please add tests covering node movement within the same tree, including verification of the
updateDepthInRange()
call and the attribute updates.
🧹 Nitpick comments (1)
src/NestedSetsUpdateManager.php (1)
246-262
: Consider caching optimization for attribute getters.The lazy loading pattern for
getLeftValue()
andgetRightValue()
is good. However, there's a minor formatting issue with extra spaces before the return statements.Apply this formatting fix:
- return $this->leftValue; + return $this->leftValue;- return $this->rightValue; + return $this->rightValue;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/NestedSetsUpdateManager.php
(1 hunks)src/QueryConditionBuilder.php
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: terabytesoftw
PR: yii2-extensions/nested-sets-behavior#13
File: src/NestedSetsBehavior.php:145-145
Timestamp: 2025-06-29T11:22:41.839Z
Learning: The user terabytesoftw prefers to keep PRs focused and small, implementing enhancements in separate dedicated PRs rather than bundling multiple changes together.
src/QueryConditionBuilder.php (1)
Learnt from: terabytesoftw
PR: yii2-extensions/nested-sets-behavior#13
File: src/NestedSetsBehavior.php:145-145
Timestamp: 2025-06-29T11:22:41.839Z
Learning: The user terabytesoftw prefers to keep PRs focused and small, implementing enhancements in separate dedicated PRs rather than bundling multiple changes together.
🧬 Code Graph Analysis (2)
src/NestedSetsUpdateManager.php (4)
src/QueryConditionBuilder.php (4)
QueryConditionBuilder
(26-147)__construct
(28-32)createCrossTreeCondition
(143-146)createSubtreeCondition
(127-130)src/UpdateExpressionBuilder.php (6)
UpdateExpressionBuilder
(30-137)__construct
(32-38)createSingleAttributeUpdate
(119-124)createSubtreeMovementAttributes
(93-109)createDepthUpdateAttributes
(77-82)createOffsetExpression
(48-53)src/NestedSetsBehavior.php (3)
moveSubtreeToTargetTree
(1389-1405)NestedSetsBehavior
(47-1423)getTreeValue
(1363-1368)tests/NestedSetsBehaviorTest.php (1)
primaryKey
(1582-1585)
src/QueryConditionBuilder.php (2)
src/UpdateExpressionBuilder.php (1)
__construct
(32-38)src/NestedSetsUpdateManager.php (1)
__construct
(65-85)
🪛 GitHub Check: codecov/patch
src/NestedSetsUpdateManager.php
[warning] 136-136: src/NestedSetsUpdateManager.php#L136
Added line #L136 was not covered by tests
[warning] 138-141: src/NestedSetsUpdateManager.php#L138-L141
Added lines #L138 - L141 were not covered by tests
[warning] 152-152: src/NestedSetsUpdateManager.php#L152
Added line #L152 was not covered by tests
[warning] 154-157: src/NestedSetsUpdateManager.php#L154-L157
Added lines #L154 - L157 were not covered by tests
[warning] 169-169: src/NestedSetsUpdateManager.php#L169
Added line #L169 was not covered by tests
[warning] 176-176: src/NestedSetsUpdateManager.php#L176
Added line #L176 was not covered by tests
[warning] 178-182: src/NestedSetsUpdateManager.php#L178-L182
Added lines #L178 - L182 were not covered by tests
src/QueryConditionBuilder.php
[warning] 82-82: src/QueryConditionBuilder.php#L82
Added line #L82 was not covered by tests
[warning] 84-88: src/QueryConditionBuilder.php#L84-L88
Added lines #L84 - L88 were not covered by tests
🪛 GitHub Check: mutation / PHP 8.4-ubuntu-latest
src/NestedSetsUpdateManager.php
[failure] 181-181:
Parameter #2 $condition of static method yii\db\ActiveRecord::updateAll() expects array|string, mixed given.
[failure] 181-181:
Call to an undefined method yii2\extensions\nestedsets\QueryConditionBuilder::reateSubtreeCondition().
🪛 GitHub Check: phpstan / PHP 8.4-ubuntu-latest
src/NestedSetsUpdateManager.php
[failure] 181-181:
Parameter #2 $condition of static method yii\db\ActiveRecord::updateAll() expects array|string, mixed given.
[failure] 181-181:
Call to an undefined method yii2\extensions\nestedsets\QueryConditionBuilder::reateSubtreeCondition().
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: codecov/project
- GitHub Check: phpunit / PHP 8.2-windows-latest
- GitHub Check: phpunit / PHP 8.4-windows-latest
- GitHub Check: phpunit / PHP 8.2-ubuntu-latest
- GitHub Check: phpunit / PHP 8.3-windows-latest
- GitHub Check: phpunit / PHP 8.3-ubuntu-latest
- GitHub Check: phpunit / PHP 8.4-ubuntu-latest
- GitHub Check: phpunit-compatibility / PHP 8.2-windows-latest
- GitHub Check: phpunit / PHP 8.1-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.1-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.1-windows-latest
🔇 Additional comments (2)
src/QueryConditionBuilder.php (1)
28-32
: Well-structured dependency injection.The constructor cleanly accepts the necessary attributes for building nested sets conditions. The readonly properties ensure immutability and thread safety.
src/NestedSetsUpdateManager.php (1)
65-85
: Excellent dependency composition and initialization.The constructor properly initializes both the condition builder and expression builder with the required attributes. The use of readonly properties ensures immutability.
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.
Actionable comments posted: 0
♻️ Duplicate comments (2)
src/NestedSetsUpdateManager.php (2)
169-184
: Correct ordering in same-tree node movement.The method appropriately calls
updateDepthInRange
first, then updates position attributes. This ordering is crucial for nested set integrity.
223-244
: Good error handling for root tree updates.The primary key validation is essential for data integrity when updating tree attributes for root nodes.
🧹 Nitpick comments (2)
src/NestedSetsUpdateManager.php (2)
252-252
: Fix extra whitespace in return statement.There's an extra space before the variable in the return statement.
- return $this->leftValue; + return $this->leftValue;
261-261
: Fix extra whitespace in return statement.There's an extra space before the variable in the return statement.
- return $this->rightValue; + return $this->rightValue;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/NestedSetsUpdateManager.php
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: terabytesoftw
PR: yii2-extensions/nested-sets-behavior#13
File: src/NestedSetsBehavior.php:145-145
Timestamp: 2025-06-29T11:22:41.839Z
Learning: The user terabytesoftw prefers to keep PRs focused and small, implementing enhancements in separate dedicated PRs rather than bundling multiple changes together.
🪛 GitHub Check: codecov/patch
src/NestedSetsUpdateManager.php
[warning] 136-136: src/NestedSetsUpdateManager.php#L136
Added line #L136 was not covered by tests
[warning] 138-141: src/NestedSetsUpdateManager.php#L138-L141
Added lines #L138 - L141 were not covered by tests
[warning] 152-152: src/NestedSetsUpdateManager.php#L152
Added line #L152 was not covered by tests
[warning] 154-157: src/NestedSetsUpdateManager.php#L154-L157
Added lines #L154 - L157 were not covered by tests
[warning] 169-169: src/NestedSetsUpdateManager.php#L169
Added line #L169 was not covered by tests
[warning] 176-176: src/NestedSetsUpdateManager.php#L176
Added line #L176 was not covered by tests
[warning] 178-182: src/NestedSetsUpdateManager.php#L178-L182
Added lines #L178 - L182 were not covered by tests
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
- GitHub Check: phpunit / PHP 8.2-windows-latest
- GitHub Check: phpunit / PHP 8.2-windows-latest
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
🔇 Additional comments (10)
src/NestedSetsUpdateManager.php (10)
1-30
: Well-structured class with comprehensive documentation.The class design follows solid principles with proper final declaration and detailed PHPDoc. The documentation clearly explains the purpose and key features.
32-57
: Good property design with appropriate type safety.Properties are well-typed with readonly modifiers where appropriate. The use of nullable types and mixed type for tree value accommodates the flexible nature of nested sets.
65-85
: Solid dependency injection pattern in constructor.The constructor properly initializes dependencies and creates the required builder instances. PHPStan annotations provide excellent type safety.
94-102
: Efficient bulk update implementation.The method correctly iterates over both left and right attributes to apply shifts, using the builder pattern for consistency.
114-126
: Proper subtree movement logic.The method correctly handles cross-tree movement with both position and depth adjustments in a single operation for efficiency.
136-142
: Correct depth update implementation.The method properly updates depth within a range using the builder pattern for condition and expression generation.
152-158
: Clean attribute adjustment method.The method provides a focused interface for adjusting specific attributes from a given value, maintaining the builder pattern consistency.
189-210
: Robust deletion handling logic.The method correctly calculates delta based on operation type and handles both leaf nodes and delete-with-children scenarios appropriately.
264-275
: Consistent tree value caching logic.The method properly handles both single-tree and multi-tree scenarios with appropriate null checks.
292-295
: Clean delegation to boundary shifting method.The method provides a clean interface that delegates to the more generic
shiftBoundaryAttributes
method with the current tree value.
Summary by CodeRabbit
Refactor
Tests