StringHumanizerExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 41
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
B getFilters() 0 30 1
1
<?php
2
3
namespace EmanueleMinotto\HumanizerBundle\Twig;
4
5
use Coduo\PHPHumanizer\StringHumanizer;
6
use Twig_SimpleFilter;
7
8
/**
9
 * Twig extension used to map StringHumanizer methods to Twig filters.
10
 *
11
 * @author Emanuele Minotto <[email protected]>
12
 */
13
class StringHumanizerExtension extends AbstractHumanizerExtension
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 45
    public function getFilters()
19
    {
20
        return [
21 45
            new Twig_SimpleFilter(
22 45
                'humanize',
23 45
                [StringHumanizer::class, 'humanize']
24 15
            ),
25 45
            new Twig_SimpleFilter(
26 45
                'truncate',
27 45
                [StringHumanizer::class, 'truncate']
28 15
            ),
29 45
            new Twig_SimpleFilter(
30 45
                'truncate_html',
31 45
                [StringHumanizer::class, 'truncateHtml'],
32
                [
33 15
                    'is_safe' => [
34 15
                        'html',
35 30
                    ],
36
                ]
37 15
            ),
38 45
            new Twig_SimpleFilter(
39 45
                'remove_shortcodes',
40 45
                [StringHumanizer::class, 'removeShortcodes']
41 15
            ),
42 45
            new Twig_SimpleFilter(
43 45
                'remove_shortcode_tags',
44 45
                [StringHumanizer::class, 'removeShortcodeTags']
45 15
            ),
46 15
        ];
47
    }
48
49 15
    public function getName()
50
    {
51 15
        return 'humanizer_string';
52
    }
53
}
54