Completed
Push — master ( 4069b9...1bd80c )
by Siro Díaz
02:06
created

TrieTree   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A numWords() 0 3 1
A size() 0 3 1
A count() 0 3 1
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
/**
12
 * TrieTree
13
 *
14
 * The TrieTree class is a trie (also called digital tree and sometimes radix tree or prefix tree)
15
 * that is used to get in O(m) being m the word length.
16
 * It is used in software like word corrector and word suggest.
17
 *
18
 * @author Siro Diaz Palazon <[email protected]>
19
 */
20
class TrieTree implements Countable {
21
    private $root;
22
    private $numWords;
23
    private $size;
24
    
25
    public function __construct() {
26
        $this->root = null;
27
        $this->numWords = 0;
28
        $this->size = 0;
29
    }
30
31
    public function numWords() : int {
32
        return $this->numWords;
33
    }
34
35
    public function size() : int {
36
        return $this->size;
37
    }
38
39
    public function count() {
40
        return $this->size();
41
    }
42
}