TwigEngineMethods   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A appliesTo() 0 3 1
A update() 0 6 2
1
<?php
2
3
/**
4
 * This file is part of template
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Slick\Template\Extension;
13
14
use Slick\Template\Engine\TwigTemplateEngine;
15
use Slick\Template\TemplateEngineInterface;
16
use Twig\Extension\ExtensionInterface;
17
18
/**
19
 * TwigEngineMethods
20
 *
21
 * @package Slick\Template\Extension
22
 */
23
trait TwigEngineMethods
24
{
25
26
    /**
27
     * @inheritDoc
28
     */
29
    public function update(TemplateEngineInterface $engine): void
30
    {
31
        if ($engine instanceof TwigTemplateEngine) {
32
            /** @var ExtensionInterface $class */
33
            $class = $this->twigExtensionName;
34
            $engine->sourceEngine()->addExtension(new $class());
35
        }
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function appliesTo(TemplateEngineInterface $engine): bool
42
    {
43
        return $engine instanceof TwigTemplateEngine;
44
    }
45
}
46