Completed
Pull Request — master (#2)
by
unknown
02:02
created

HTML5CacheExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 8 1
A getCacheManifest() 0 4 2
A getName() 0 4 1
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
    /**
14
     * @return \Twig_SimpleFunction[]
15
     */
16
    public function getFunctions()
17
    {
18
      return [
19
                 new \Twig_SimpleFunction('cache_manifest', [$this, 'getCacheManifest'], [
20
                     'needs_environment' => true
21
                 ])
22
             ];
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    public function getCacheManifest(\Twig_Environment $environment)
29
    {
30
        return $environment->isDebug() ? '' : ' manifest="/cache.manifest"';
31
    }
32
33
    /**
34
     * Returns the name of the extension.
35
     *
36
     * @return string The extension name
37
     */
38
    public function getName()
39
    {
40
        return 'html5_cache_extension';
41
    }
42
}
43