Completed
Push — master ( 74371a...6da8c0 )
by Vladimir
02:21
created

TwigExtension::getFilters()   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 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Templating\Twig;
9
10
use allejo\stakx\Command\BuildableCommand;
11
use allejo\stakx\Service;
12
use allejo\stakx\Templating\Twig\Extension\AbstractTwigExtension;
13
use allejo\stakx\Templating\Twig\Extension\TwigFilterInterface;
14
use allejo\stakx\Templating\Twig\Extension\TwigFunctionInterface;
15
16
class TwigExtension extends \Twig_Extension
17
{
18
    private $filters = [];
19
    private $functions = [];
20
21 18 View Code Duplication
    public function addFilters(/*iterable*/ $filters)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        /** @var AbstractTwigExtension|TwigFilterInterface $filter */
24 18
        foreach ($filters as $filter)
25
        {
26 18
            if (Service::getParameter(BuildableCommand::SAFE_MODE) && $filter::disableInSafeMode())
27
            {
28
                continue;
29
            }
30
31 18
            $this->filters[] = $filter::get();
32
        }
33 18
    }
34
35 View Code Duplication
    public function addFunctions(/*iterable*/ $functions)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        /** @var AbstractTwigExtension|TwigFunctionInterface $fxn */
38
        foreach ($functions as $fxn)
39
        {
40
            if (Service::getParameter(BuildableCommand::SAFE_MODE) && $fxn::disableInSafeMode())
41
            {
42
                continue;
43
            }
44
45
            $this->functions[] = $fxn::get();
46
        }
47
    }
48
49 6
    public function getFilters()
50
    {
51 6
        return $this->filters;
52
    }
53
54 6
    public function getFunctions()
55
    {
56 6
        return $this->functions;
57
    }
58
59 30
    public function getName()
60
    {
61 30
        return 'stakx_twig_base_extension';
62
    }
63
}
64