HTML5CacheExtension::getCacheManifest()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace Evheniy\HTML5CacheBundle\Twig;
4
5
/**
6
 * Class HTML5CacheExtension
7
 *
8
 * @package Evheniy\HTML5CacheBundle\Twig
9
 */
10
class HTML5CacheExtension extends \Twig_Extension
11
{
12
    /**
13
     * @var \Twig_Environment
14
     */
15
    protected $environment;
16
17
    /**
18
     * @return \Twig_SimpleFunction[]
19
     */
20
    public function getFunctions()
21
    {
22
        return array(
23
            new \Twig_SimpleFunction('cache_manifest', array($this, 'getCacheManifest'))
24
        );
25
    }
26
27
    /**
28
     * @param \Twig_Environment $environment
29
     * @return HTML5CacheExtension
30
     */
31
    public function initRuntime(\Twig_Environment $environment)
32
    {
33
        $this->environment = $environment;
34
        return $this;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getCacheManifest()
41
    {
42
        return $this->environment->isDebug() ? '' : ' manifest="/cache.manifest"';
43
    }
44
45
    /**
46
     * Returns the name of the extension.
47
     *
48
     * @return string The extension name
49
     */
50
    public function getName()
51
    {
52
        return 'html5_cache_extension';
53
    }
54
55
}