Code Duplication    Length = 10-11 lines in 3 locations

DataStructures/Trees/BinaryTreeAbstract.php 3 locations

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