Code Duplication    Length = 21-21 lines in 2 locations

DataStructures/Trees/AVLTree.php 2 locations

@@ 41-61 (lines=21) @@
38
        return new AVLNode($key, $data, $parent, $left, $right);
39
    }
40
41
    private function rightRotation(AVLNode $node) {
42
        $tempParent = &$node->parent;
43
        $tempRight = &$node->right;
44
        $veryChildren = &$tempRight->left;
45
46
        if($tempParent === null) {
47
            $this->root = &$tempRight;
48
            $tempRight->parent = null;
49
        } else {
50
            $tempRight->parent = &$tempParent;
51
            if($tempRight->key < $tempParent->key) {
52
                $tempParent->left = &$tempRight;
53
            } else {
54
                $tempParent->right = &$tempRight;
55
            }
56
        }
57
58
        $parentRight->left = &$node;
59
        $node->parent = &$tempRight;
60
        $node->right = &$veryChildren;
61
    }
62
63
    private function leftRotation(AVLNode $node) {
64
        $tempParent = &$node->parent;
@@ 63-83 (lines=21) @@
60
        $node->right = &$veryChildren;
61
    }
62
63
    private function leftRotation(AVLNode $node) {
64
        $tempParent = &$node->parent;
65
        $tempLeft = &$node->left;
66
        $veryChildren = &$tempLeft->right;
67
68
        if($tempParent === null) {
69
            $this->root = &$tempLeft;
70
            $tempLeft->parent = null;
71
        } else {
72
            $tempLeft->parent = &$tempParent;
73
            if($tempLeft->key < $tempParent->key) {
74
                $tempParent->left = &$tempLeft;
75
            } else {
76
                $tempParent->right = &$tempLeft;
77
            }
78
        }
79
    
80
        $tempLeft->right = &$node;
81
        $node->parent = &$tempLeft;
82
        $node->left = &$veryChildren;
83
    }
84
85
    private function doubleRightRotation(AVLNode $node) {
86
        $node->right = $this->rightRotation($node->right);