Passed
Push — master ( 39a592...c8460b )
by Dāvis
02:48
created

TwigTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 23
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A makeArray() 0 19 3
1
<?php
2
3
namespace Sludio\HelperBundle\Script\Twig;
4
5
trait TwigTrait
6
{
7
    protected $shortFunctions;
8
9
    public function makeArray(array $input, $type = 'filter')
10
    {
11
        $output = [];
12
        $class = '\\Twig_Simple'.ucfirst($type);
13
14
        foreach ($input as $call => $function) {
15
            $output[] = new $class('sludio_'.$call, [
16
                $this,
17
                $function,
18
            ]);
19
            if ($this->shortFunctions) {
20
                $output[] = new $class($call, [
21
                    $this,
22
                    $function,
23
                ]);
24
            }
25
        }
26
27
        return $output;
28
    }
29
}