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

TwigEngineMethods   A

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\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