ObjectRenderExtension::locateFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Psi\Bundle\ObjectRender\Twig;
4
5
use Psi\Bundle\ObjectRender\Template\Locator;
6
use Psi\Bundle\ObjectRender\Twig\Node\RenderObjectNode;
7
8
class ObjectRenderExtension extends \Twig_Extension
9
{
10
    private $locator;
11
12
    public function __construct(Locator $locator)
13
    {
14
        $this->locator = $locator;
15
    }
16
17
    public function getFunctions()
18
    {
19
        return [
20
            new \Twig_SimpleFunction('psi_render_object', null, [
21
                'node_class' => RenderObjectNode::class,
22
            ], [
0 ignored issues
show
Unused Code introduced by
The call to Twig_SimpleFunction::__construct() has too many arguments starting with array('is_safe' => array('html')).

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...
23
                'is_safe' => ['html'],
24
            ]),
25
        ];
26
    }
27
28
    public function locateFile($object)
29
    {
30
        $reflection = new \ReflectionClass($object);
31
32
        return $this->locator->locate($reflection);
33
    }
34
}
35