Skip to content

Commit 1f044c5

Browse files
committed
🚨 Fix classes complexity
1 parent 3b45692 commit 1f044c5

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎src/SortedCollection/SubMap.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @property mixed $toKey The to key
3838
* @property boolean $toInclusive The to inclusive flag
3939
* @property-read SortedMap $map The underlying map
40+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
4041
*/
4142
class SubMap extends AbstractMap
4243
{

‎src/SortedCollection/TreeNode.php‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @property-read TreeNode|null $successor The successor node
2828
* @property-read mixed $key The key
2929
* @property-read integer $count The number of elements in the tree
30+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
3031
*/
3132
class TreeNode implements \Countable
3233
{
@@ -135,6 +136,10 @@ public function __get($property)
135136
return $this->getMappedProperty($property);
136137
}
137138

139+
/*
140+
* Private helpers: magic property access
141+
*/
142+
138143
/**
139144
* Resolve mapped magic property
140145
*
@@ -292,6 +297,10 @@ public function find($key, $comparator, $type = 0)
292297
return $this->resolveFindResult($node, $cmp, $type);
293298
}
294299

300+
/*
301+
* Private helpers: find resolution
302+
*/
303+
295304
/**
296305
* Traverse tree for find operation
297306
*
@@ -404,7 +413,6 @@ private function resolveFindResultForPositiveCmp($node, $type)
404413
*/
405414
private function resolveFindResultForZeroCmp($node, $type)
406415
{
407-
408416
if ($type < -1) {
409417
return $node->predecessor;
410418
}
@@ -416,6 +424,10 @@ private function resolveFindResultForZeroCmp($node, $type)
416424
return $node;
417425
}
418426

427+
/*
428+
* Private helpers: balancing and rotations
429+
*/
430+
419431
/**
420432
* Rotate the node to the left
421433
*
@@ -566,6 +578,10 @@ public function insert($key, $value, $comparator)
566578
return $this->insertHere($value);
567579
}
568580

581+
/*
582+
* Private helpers: insert
583+
*/
584+
569585
/**
570586
* Insert into the left subtree
571587
*
@@ -662,6 +678,10 @@ private function insertHere($value)
662678
return $this;
663679
}
664680

681+
/*
682+
* Private helpers: pull-up left-most
683+
*/
684+
665685
/**
666686
* Pull up the left most node of a node
667687
*
@@ -763,6 +783,10 @@ public function remove($key, $comparator)
763783
return $this->removeCurrent();
764784
}
765785

786+
/*
787+
* Private helpers: remove
788+
*/
789+
766790
/**
767791
* Remove from left subtree
768792
*
@@ -882,7 +906,6 @@ private function removeCurrentWithRightChild()
882906
*/
883907
private function removeCurrentWithoutRightChild()
884908
{
885-
886909
$left = $this->left;
887910
$right = $this->right;
888911

0 commit comments

Comments
 (0)