Completed
Push — 4.0 ( 87d096...bcc1be )
by Kiyotaka
05:44 queued 11s
created

TwigIncludeExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFunctions() 0 7 1
A include_dispatch() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Twig\Extension;
15
16
use Twig\Extension\AbstractExtension;
17
18
class TwigIncludeExtension extends AbstractExtension
19
{
20
    protected $twig;
21
22 470
    public function __construct(\Eccube\Twig\Environment $twig)
23
    {
24 470
        $this->twig = $twig;
25
    }
26
27 241
    public function getFunctions()
28
    {
29
        return [
30 241
            new \Twig_Function('include_dispatch', [$this, 'include_dispatch'],
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Function has been deprecated with message: since Twig 2.7, use "Twig\TwigFunction" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
31 241
                ['needs_context' => true, 'is_safe' => ['all']]),
32
        ];
33
    }
34
35 113
    public function include_dispatch($context, $template, $variables = [])
36
    {
37 113
        if (!empty($variables)) {
38
            $context = array_merge($context, $variables);
39
        }
40
41 113
        return $this->twig->render($template, $context);
42
    }
43
}
44