Passed
Push — master ( 11e596...ed648f )
by Gabriel
13:25
created

HasMethodsTrait::setEngineMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Nip\View\Traits;
4
5
use Closure;
6
use Nip\View\Methods\MethodsCollection;
0 ignored issues
show
Bug introduced by
The type Nip\View\Methods\MethodsCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Nip\View\Methods\Pipeline\Stages\MethodCollectionStage;
0 ignored issues
show
Bug introduced by
The type Nip\View\Methods\Pipelin...s\MethodCollectionStage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Trait HasMethodsTrait
11
 * @package Nip\View\Traits
12
 */
13
trait HasMethodsTrait
14
{
15
    /**
16
     * Magic method used to call extension functions.
17 11
     * @param  string $name
18
     * @param  array  $arguments
19 11
     * @return mixed
20 11
     */
21
    public function __call($name, $arguments)
22
    {
23
        return $this->getFunction($name)->call(null, $arguments);
0 ignored issues
show
Bug introduced by
The method getFunction() does not exist on Nip\View\Traits\HasMethodsTrait. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        return $this->/** @scrutinizer ignore-call */ getFunction($name)->call(null, $arguments);
Loading history...
24
    }
25 11
26
    /**
27 11
     * @param $name
28 11
     * @param Closure $callable
29
     */
30
    public function addMethod($name, Closure $callable)
31 11
    {
32
        $this->registerFunction($name, $callable);
0 ignored issues
show
Bug introduced by
The method registerFunction() does not exist on Nip\View\Traits\HasMethodsTrait. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $this->/** @scrutinizer ignore-call */ 
33
               registerFunction($name, $callable);
Loading history...
33
    }
34
35
    /**
36
     * @param Closure[] $methods
37 11
     */
38
    public function addMethods(array $methods)
39 11
    {
40 11
        foreach ($methods as $name => $closure) {
41
            $this->addMethod($name, $closure);
42
        }
43
    }
44
}
45