Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
40.00% |
2 / 5 |
CRAP | |
78.95% |
15 / 19 |
BinaryTreeNode | |
0.00% |
0 / 1 |
|
40.00% |
2 / 5 |
9.76 | |
78.95% |
15 / 19 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
4 / 4 |
|||
left | |
0.00% |
0 / 1 |
3.04 | |
83.33% |
5 / 6 |
|||
right | |
0.00% |
0 / 1 |
3.04 | |
83.33% |
5 / 6 |
|||
get | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
set | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
<?php | |
namespace Mtkocak\DataStructures; | |
use Exception; | |
class BinaryTreeNode implements TreeNodeInterface | |
{ | |
private $data; | |
public $left; | |
public $right; | |
function __construct($data) | |
{ | |
$this->data = $data; | |
$this->left = NULL; | |
$this->right = NULL; | |
} | |
public function left(TreeNodeInterface &$node = NULL) | |
{ | |
if (isset($node)) { | |
if ($this->left != NULL) { | |
throw new Exception("Node Not Empty"); | |
} else { | |
$this->left = $node; | |
} | |
} | |
return $this->left; | |
} | |
public function right(TreeNodeInterface &$node = NULL) | |
{ | |
if (isset($node)) { | |
if ($this->right != NULL) { | |
throw new Exception("Node Not Empty"); | |
} else { | |
$this->right = $node; | |
} | |
} | |
return $this->right; | |
} | |
public function get() | |
{ | |
return $this->data; | |
} | |
public function set($value) | |
{ | |
$this->data = $value; | |
} | |
} |