Completed
Push — master ( f1605c...0f0c8b )
by Siro Díaz
02:06
created

BinarySearchTree   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 11
loc 11
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A createNode() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * DataStructures for PHP
4
 *
5
 * @link      https://github.com/SiroDiaz/DataStructures
6
 * @copyright Copyright (c) 2017 Siro Díaz Palazón
7
 * @license   https://github.com/SiroDiaz/DataStructures/blob/master/README.md (MIT License)
8
 */
9
namespace DataStructures\Trees;
10
11
use DataStructures\Trees\Nodes\BSTNode;
12
use DataStructures\Trees\BinaryTreeAbstract;
13
14
/**
15
 * BinarySearchTree
16
 * 
17
 * Represents a BST actions that can be realized. All the implementation
18
 * is in BinaryTreeAbstract class.
19
 * At the beginning root is null and it can grow up to a O(n) in search,
20
 * delete and insert (in worst case). In best cases it will be O(log n).
21
 *
22
 * @author Siro Diaz Palazon <[email protected]>
23
 */
24 View Code Duplication
class BinarySearchTree extends BinaryTreeAbstract {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
26
    public function __construct() {
27
        $this->root = null;
28
        $this->size = 0;
29
    }
30
31
    public function createNode($key, $data, $parent = null, $left = null, $right = null) {
32
        return new BSTNode($key, $data, $parent, $left, $right);
33
    }
34
}