Completed
Push — master ( f339fb...41f35e )
by Filipe
08:39
created

AbstractTwigExtension::appliesTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of slick/template package
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
namespace Slick\Template\Extension;
11
12
use Slick\Template\Engine\Twig;
13
use Slick\Template\TemplateEngineInterface;
14
15
/**
16
 * Abstract Twig Extension
17
 *
18
 * @package Slick\Template\Extension
19
 * @author  Filipe Silva <[email protected]>
20
 */
21
abstract class AbstractTwigExtension extends \Twig_Extension
22
{
23
24
    /**
25
     * Updates the engine with this extension
26
     *
27
     * @param TemplateEngineInterface|Twig $engine
28
     *
29
     * @return void
30
     */
31 2
    public function update(TemplateEngineInterface $engine)
32
    {
33 2
        $engine->getSourceEngine()->addExtension($this);
34 2
    }
35
36
    /**
37
     * Check if this extension is applicable to provided engine object
38
     *
39
     * @param TemplateEngineInterface $engine
40
     *
41
     * @return bool True if this extension applies to provided engine object
42
     *      or false otherwise
43
     */
44 2
    public function appliesTo(TemplateEngineInterface $engine)
45
    {
46 2
        return $engine instanceOf Twig;
47
    }
48
}
49