StringHumanizerExtension::getFilters()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 25
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 25
cts 25
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 0
crap 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