Completed
Push — development ( ef9e73...b2c3e4 )
by Andrij
20:27
created

TwigExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getFilters() 0 9 1
A getFunctions() 0 7 1
A getName() 0 3 1
1
<?php namespace CMSFactory\Templating\Twig\Extension;
2
3
use CMSFactory\Services\Morphy\Morphy;
4
use Twig_Extension;
5
6
class TwigExtension extends Twig_Extension
7
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
8
9
    private $morphy;
10
11
    public function __construct(Morphy $morphy) {
12
        $this->morphy = $morphy;
13
    }
14
15
    public function getFilters() {
16
        return [
17
                new \Twig_SimpleFilter('translit', 'translit'),
18
                new \Twig_SimpleFilter('morphy', [$this->morphy, 'morphy']),
19
                new \Twig_SimpleFilter('dump', 'dump'),
20
                new \Twig_SimpleFilter('dd', 'dd'),
21
                new \Twig_SimpleFilter('lang', 'lang'),
22
               ];
23
    }
24
25
    public function getFunctions() {
26
        return [
27
                new \Twig_SimpleFunction('dump', 'dump'),
28
                new \Twig_SimpleFunction('dd', 'dd'),
29
                new \Twig_SimpleFunction('lang', 'lang'),
30
               ];
31
    }
32
33
    /**
34
     * Returns the name of the extension.
35
     *
36
     * @return string The extension name
37
     */
38
    public function getName() {
39
        return 'icms';
40
    }
41
}