Code Duplication    Length = 10-11 lines in 3 locations

DataStructures/Trees/BinaryTreeAbstract.php 3 locations

@@ 454-463 (lines=10) @@
451
     * @param Callable|null $callback the callback function to apply to each
452
     *  node.
453
     */
454
    private function _preorder($node, Callable $callback = null) {
455
        if($node === null) {
456
            return;
457
        }
458
        if($callback !== null) {
459
            call_user_func($callback, $node);
460
        }
461
        $this->_preorder($node->left, $callback);
462
        $this->_preorder($node->right, $callback);
463
    }
464
465
    /**
466
     * Traverse in inorder. This is: first visit the left subtree,
@@ 484-494 (lines=11) @@
481
     * @param Callable|null $callback the callback function to apply to each
482
     *  node.
483
     */
484
    private function _inorder($node, Callable $callback = null) {
485
        if($node === null) {
486
            return;
487
        }
488
489
        $this->_inorder($node->left, $callback);
490
        if($callback !== null) {
491
            call_user_func($callback, $node);
492
        }
493
        $this->_inorder($node->right, $callback);
494
    }
495
496
    /**
497
     * Traverse in postorder. This is: first visit the left subtree,
@@ 515-524 (lines=10) @@
512
     * @param Callable|null $callback the callback function to apply to each
513
     *  node.
514
     */
515
    private function _postorder($node, Callable $callback = null) {
516
        if($node === null) {
517
            return;
518
        }
519
        $this->_postorder($node->left, $callback);
520
        $this->_postorder($node->right, $callback);
521
        if($callback !== null) {
522
            call_user_func($callback, $node);
523
        }
524
    }
525
}