Code Duplication    Length = 10-11 lines in 3 locations

DataStructures/Trees/BinarySearchTree.php 3 locations

@@ 424-433 (lines=10) @@
421
        $this->_preorder($this->root, $callback);
422
    }
423
424
    private function _preorder($node, Callable $callback = null) {
425
        if($node === null) {
426
            return;
427
        }
428
        if($callback !== null) {
429
            call_user_func($callback, $node);
430
        }
431
        $this->_preorder($node->left, $callback);
432
        $this->_preorder($node->right, $callback);
433
    }
434
435
    /**
436
     * Traverse in inorder. This is: first visit the left subtree,
@@ 443-453 (lines=11) @@
440
        $this->_inorder($this->root);
441
    }
442
443
    private function _inorder($node, Callable $callback = null) {
444
        if($node === null) {
445
            return;
446
        }
447
448
        $this->_inorder($node->left, $callback);
449
        if($callback !== null) {
450
            call_user_func($callback, $node);
451
        }
452
        $this->_inorder($node->right, $callback);
453
    }
454
455
    /**
456
     * Traverse in postorder. This is: first visit the left subtree,
@@ 471-480 (lines=10) @@
468
     * @param Callable|null $callback the callback function to apply to each
469
     *  node.
470
     */
471
    private function _postorder($node, Callable $callback = null) {
472
        if($node === null) {
473
            return;
474
        }
475
        $this->_postorder($node->left, $callback);
476
        $this->_postorder($node->right, $callback);
477
        if($callback !== null) {
478
            call_user_func($callback, $node);
479
        }
480
    }
481
482
    /**
483
     * Binds to count() method. This is equal to make $this->tree->size().