Template::algorithm()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 17
rs 9.2
cc 4
eloc 12
nc 4
nop 1
1
<?php
2
namespace Autocomplete\Container\Trie\Method;
3
4
abstract class Template
5
{
6
7
    public $char;
8
    public $child;
9
    public $word;
10
11
    final public function execute($string, &$child)
12
    {
13
       $this->word = (join($string));
14
       $this->child = $child;
15
       return $this->algorithm($string, $child);
0 ignored issues
show
Unused Code introduced by
The call to Template::algorithm() has too many arguments starting with $child.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
16
    }
17
18
    final public function algorithm($string)
19
    {
20
        if (count($string) < 1) {
21
            return $this->ifStringEnd();
22
        }
23
        $this->char = array_shift($string);
24
        $prevChild = $this->child;
25
        $this->child = $this->child->getChild($this->char);
26
        if ( ! $this->child) {
27
            $ret = $this->childIsInvalid($prevChild);
28
            $this->child = $ret['returnValue'];
29
            if ($ret['return']) {
30
                return $ret['returnValue'];
31
            }
32
        }
33
        return $this->algorithm($string);
34
    }
35
36
    abstract public function ifStringEnd();
37
    abstract public function childIsInvalid(&$prevChild);
38
}
39