Passed
Pull Request — master (#48)
by Emanuele
13:20
created

FeatureNode::createExpression()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 14
nc 1
nop 3
dl 0
loc 20
ccs 15
cts 15
cp 1
crap 2
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Ae\FeatureBundle\Twig\Node;
4
5
use Ae\FeatureBundle\Twig\Extension\FeatureExtension;
6
use Twig_Environment;
7
use Twig_Node;
8
use Twig_Node_Expression_Array;
9
use Twig_Node_Expression_Constant;
10
use Twig_Node_Expression_ExtensionReference;
11
use Twig_Node_Expression_MethodCall;
12
use Twig_Node_If;
13
14
/**
15
 * @author Carlo Forghieri <[email protected]>
16
 */
17
class FeatureNode extends Twig_Node_If
18
{
19 3
    public function __construct($name, $parent, $body, $else, $lineno, $tag = null)
20
    {
21 3
        $tests = new Twig_Node([
22 3
            $this->createExpression($name, $parent, $lineno),
23 3
            $body,
24
        ]);
25
26 3
        parent::__construct($tests, $else, $lineno, $tag);
27 3
    }
28
29 3
    protected function createExpression($name, $parent, $lineno)
30
    {
31 3
        return new Twig_Node_Expression_MethodCall(
32 3
            new Twig_Node_Expression_ExtensionReference(
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Node_Expression_ExtensionReference has been deprecated: since 1.23 and will be removed in 2.0. ( Ignorable by Annotation )

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

32
            /** @scrutinizer ignore-deprecated */ new Twig_Node_Expression_ExtensionReference(
Loading history...
33 3
                version_compare(Twig_Environment::VERSION, '1.26.0', '>=')
34 3
                    ? FeatureExtension::class
35 3
                    : 'feature',
36 3
                $lineno
37
            ),
38 3
            'isGranted',
39 3
            new Twig_Node_Expression_Array(
40
                [
41 3
                    new Twig_Node_Expression_Constant('name', $lineno),
42 3
                    new Twig_Node_Expression_Constant($name, $lineno),
43 3
                    new Twig_Node_Expression_Constant('parent', $lineno),
44 3
                    new Twig_Node_Expression_Constant($parent, $lineno),
45
                ],
46 3
                $lineno
47
            ),
48 3
            $lineno
49
        );
50
    }
51
}
52