| 1 | <?php | ||
| 21 | class TrieNode implements Countable { | ||
| 22 | public $char; | ||
| 23 | public $isWord; | ||
| 24 | public $children; | ||
| 25 | public $parent; | ||
| 26 | |||
| 27 |     public function __construct($char = '', &$parent = null, $isWord = false) { | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Returns if the node has children. | ||
| 36 | * | ||
| 37 | * @return bool true if there is one or more children. | ||
| 38 | */ | ||
| 39 |     public function hasChildren() : bool { | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Returns if the node is leaf: it has not children nodes and | ||
| 45 | * it is not root. | ||
| 46 | * | ||
| 47 | * @return bool true if is leaf. | ||
| 48 | */ | ||
| 49 |     public function isLeaf() : bool { | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Checks if is the node is root. | ||
| 55 | * | ||
| 56 | * @return bool true is it has not parent node. | ||
| 57 | */ | ||
| 58 |     public function isRoot() : bool { | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Returns the number of children. Binds count(). | ||
| 64 | * | ||
| 65 | * @return int The node count. | ||
| 66 | */ | ||
| 67 |     public function count() { | ||
| 70 | } |