TypographTwigExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A getFilters() 0 6 1
A applyTypograph() 0 4 1
1
<?php
2
3
namespace Fenrizbes\TypographBundle\Twig;
4
5
use Fenrizbes\TypographBundle\Service\TypographService;
6
7
class TypographTwigExtension extends \Twig_Extension
8
{
9
    protected $typograph;
10
11
    public function __construct(TypographService $typograph)
12
    {
13
        $this->typograph = $typograph;
14
    }
15
16
    public function getName()
17
    {
18
        return 'FenrizbesTypograph';
19
    }
20
21
    public function getFilters()
22
    {
23
        return array(
24
            new \Twig_SimpleFilter('typograph', array($this, 'applyTypograph'), array('is_safe' => array('html')))
25
        );
26
    }
27
28
    public function applyTypograph($string, $config = null)
29
    {
30
        return $this->typograph->apply($string, $config);
31
    }
32
}