Completed
Push — master ( 0a933f...8a8a33 )
by Ma
02:04
created

Template::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
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
    public final function execute($string, &$child)
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
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
    public final function algorithm($string)
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
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, $this->child);
0 ignored issues
show
Unused Code introduced by
The call to Template::algorithm() has too many arguments starting with $this->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...
34
    }
35
36
    abstract public function ifStringEnd();
37
    abstract public function childIsInvalid(&$prevChild);
38
}