CollectionHumanizerExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 26
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getFilters() 0 15 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