CollectionHumanizerExtension::getFilters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 14
cts 14
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
crap 1
1
<?php
2
3
namespace EmanueleMinotto\HumanizerBundle\Twig;
4
5
use Coduo\PHPHumanizer\CollectionHumanizer;
6
use Twig_SimpleFilter;
7
8
/**
9
 * Twig extension used to map CollectionHumanizer methods to Twig filters.
10
 *
11
 * @author Emanuele Minotto <[email protected]>
12
 */
13
class CollectionHumanizerExtension extends AbstractHumanizerExtension
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 45
    public function getFilters()
19 1
    {
20 1
        return [
21 45
            new Twig_SimpleFilter(
22 45
                'oxford',
23 31
                function ($collection, $limit = null) {
24 3
                    return CollectionHumanizer::oxford(
25 2
                        $collection,
26 2
                        $limit,
27 3
                        $this->translator->getLocale()
28 1
                    );
29 30
                }
30 15
            ),
31 15
        ];
32
    }
33
34 15
    public function getName()
35
    {
36 15
        return 'humanizer_collection';
37
    }
38
}
39