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

TwigTrait::makeArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 19
rs 9.4285
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
}