Completed
Push — master ( a9994d...fef649 )
by Philip
07:17
created

TwigExtensions   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerTwigExtensions() 0 7 1
A arrayColumn() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the CRUDlex package.
5
 *
6
 * (c) Philip Lehmann-Böhm <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CRUDlex;
13
14
use Pimple\Container;
15
16
/**
17
 * Provides and setups the Twig extensions like filters.
18
 */
19
class TwigExtensions {
20
21
    /**
22
     * Registers all extensions.
23
     *
24
     * @param Container $app
25
     * the current application
26
     */
27
    public function registerTwigExtensions(Container $app) {
28
        $self = $this;
29
        $app->extend('twig', function($twig, $app) use ($self) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
            $twig->addFilter(new \Twig_SimpleFilter('arrayColumn', [$self, 'arrayColumn']));
31
            return $twig;
32
        });
33
    }
34
    /**
35
     * To have array_column available as Twig filter.
36
     *
37
     * @param $array
38
     * the array
39
     * @param $key
40
     * the key
41
     *
42
     * @return array
43
     * the resulting array
44
     */
45
    public function arrayColumn($array, $key) {
46
        return array_column($array, $key);
47
    }
48
49
}