Utils   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 32
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilters() 0 14 1
A getName() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of TwigView.
6
 *
7
 ** (c) 2014 Cees-Jan Kiewiet
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace WyriHaximus\TwigView\Lib\Twig\Extension;
14
15
use Twig\Extension\AbstractExtension;
16
use Twig\TwigFilter;
17
18
/**
19
 * Class Utils.
20
 * @package WyriHaximus\TwigView\Lib\Twig\Extension
21
 */
22
final class Utils extends AbstractExtension
23
{
24
    /**
25
     * Get declared filters.
26
     *
27
     * @return \Twig\TwigFilter[]
28
     */
29
    public function getFilters(): array
30
    {
31
        return [
32
            new TwigFilter('serialize', 'serialize'),
33
            new TwigFilter('unserialize', 'unserialize'),
34
            new TwigFilter('md5', 'md5'),
35
            new TwigFilter('base64_encode', 'base64_encode'),
36
            new TwigFilter('base64_decode', 'base64_decode'),
37
            new TwigFilter('nl2br', 'nl2br'),
38
            new TwigFilter('string', function ($str) {
39
                return (string)$str;
40
            }),
41
        ];
42
    }
43
44
    /**
45
     * Get extension name.
46
     *
47
     * @return string
48
     */
49
    public function getName(): string
50
    {
51
        return 'utils';
52
    }
53
}
54