Passed
Push — master ( 2a327d...e16666 )
by Filipe
01:33 queued 14s
created

TwigEngineMethods::appliesTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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\Extension\Twig\TwigTextExtension;
16
use Slick\Template\TemplateEngineInterface;
17
use Twig\Extension\ExtensionInterface;
18
19
/**
20
 * TwigEngineMethods
21
 *
22
 * @package Slick\Template\Extension
23
 */
24
trait TwigEngineMethods
25
{
26
27
    /**
28
     * @inheritDoc
29
     */
30
    public function update(TemplateEngineInterface $engine): void
31
    {
32
        if ($engine instanceof TwigTemplateEngine) {
33
            /** @var ExtensionInterface $class */
34
            $class = $this->twigExtensionName;
35
            $engine->sourceEngine()->addExtension(new $class());
36
        }
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function appliesTo(TemplateEngineInterface $engine): bool
43
    {
44
        return $engine instanceof TwigTemplateEngine;
45
    }
46
}
47