Completed
Push — master ( f9653e...3d171c )
by Rafał
11:41 queued 08:40
created

AmpExtension::getFilters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the takeit/AmpHtmlBundle package.
5
 *
6
 * (c) Rafał Muszyński <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Takeit\Bundle\AmpHtmlBundle\Twig;
13
14
/**
15
 * AMP Twig Extension.
16
 */
17
class AmpExtension extends \Twig_Extension
18
{
19
    /**
20
     * @var array
21
     */
22
    private $config;
23
24
    /**
25
     * @param array $config
26
     */
27
    public function __construct(array $config)
28
    {
29
        $this->config = $config;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getFilters()
36
    {
37
        return array(
38
            new \Twig_SimpleFilter('amp_path', array($this, 'ampFilter')),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFilter has been deprecated with message: to be removed in 3.0

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
39
        );
40
    }
41
42
    /**
43
     * Returns an AMP path.
44
     *
45
     * @param $path Path
46
     *
47
     * @return string
48
     */
49
    public function ampFilter($path)
50
    {
51
        return $this->config['prefix'].$path;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getName()
58
    {
59
        return 'takeit_amp_extension';
60
    }
61
}
62