@@ -21,6 +21,9 @@ |
||
21 | 21 | */ |
22 | 22 | private $endNode; |
23 | 23 | |
24 | + /** |
|
25 | + * @param string $value |
|
26 | + */ |
|
24 | 27 | public function __construct($value) |
25 | 28 | { |
26 | 29 | $this->value = $value; |
@@ -8,6 +8,9 @@ |
||
8 | 8 | public $child; |
9 | 9 | public $word; |
10 | 10 | |
11 | + /** |
|
12 | + * @param \Autocomplete\Container\Trie\Node $child |
|
13 | + */ |
|
11 | 14 | public final function execute($string, &$child) |
12 | 15 | { |
13 | 16 | $this->word = (join($string)); |
@@ -10,9 +10,9 @@ |
||
10 | 10 | |
11 | 11 | public final function execute($string, &$child) |
12 | 12 | { |
13 | - $this->word = (join($string)); |
|
14 | - $this->child = $child; |
|
15 | - return $this->algorithm($string, $child); |
|
13 | + $this->word = (join($string)); |
|
14 | + $this->child = $child; |
|
15 | + return $this->algorithm($string, $child); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public final function algorithm($string) |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $input = fgets(STDIN, 1024); |
23 | 23 | $input = trim($input); |
24 | 24 | parseInput($input, $trie); |
25 | - if($input == 'quit') $running = false; |
|
25 | + if ($input == 'quit') $running = false; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | function parseInput($input, $trie) |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | if ($wordLen < $minLen) { |
46 | 46 | return false; |
47 | 47 | } |
48 | - for ($i=$wordLen; $i > $minSearch; $i--) { |
|
49 | - $wordPreffix = substr($word,0 , $i); |
|
48 | + for ($i = $wordLen; $i > $minSearch; $i--) { |
|
49 | + $wordPreffix = substr($word, 0, $i); |
|
50 | 50 | $words = $trie->getByPrefix($wordPreffix); |
51 | 51 | //return first element of $words array |
52 | 52 | return reset($words); |
@@ -22,8 +22,10 @@ |
||
22 | 22 | $input = fgets(STDIN, 1024); |
23 | 23 | $input = trim($input); |
24 | 24 | parseInput($input, $trie); |
25 | - if($input == 'quit') $running = false; |
|
26 | -} |
|
25 | + if($input == 'quit') { |
|
26 | + $running = false; |
|
27 | + } |
|
28 | + } |
|
27 | 29 | |
28 | 30 | function parseInput($input, $trie) |
29 | 31 | { |