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

TwigTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
B makeArray() 0 22 4
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', $onlyShort = false)
10
    {
11
        if($onlyShort){
12
            $this->shortFunctions = true;
13
        }
14
        $output = [];
15
        $class = '\\Twig_Simple'.ucfirst($type);
16
17
        foreach ($input as $call => $function) {
18
            $output[] = new $class('sludio_'.$call, [
19
                $this,
20
                $function,
21
            ]);
22
            if ($this->shortFunctions) {
23
                $output[] = new $class($call, [
24
                    $this,
25
                    $function,
26
                ]);
27
            }
28
        }
29
30
        return $output;
31
    }
32
}