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

TwigExtension::addFilters()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 5

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 4.074

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 13
loc 13
ccs 5
cts 6
cp 0.8333
rs 9.2
cc 4
eloc 5
nc 3
nop 1
crap 4.074
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