Completed
Push — master ( 21a372...15484d )
by Ivo
06:21
created

MoneyExtension::getFilters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ivoba\Money\Twig;
4
5
use Ivoba\Money\Formatter\MoneyFormatter;
6
7
class MoneyExtension extends \Twig_Extension
8
{
9
10
    private $moneyFormatter;
11
12
    /**
13
     * @param MoneyFormatter $moneyFormatter
14
     */
15 3
    public function __construct(MoneyFormatter $moneyFormatter)
16
    {
17 3
        $this->moneyFormatter = $moneyFormatter;
18 3
    }
19
20
    /**
21
     * @return array
22
     */
23 3
    public function getFilters()
24
    {
25
        return [
26 3
            new \Twig_SimpleFilter('money_i18n_format', [$this->moneyFormatter, 'formatI18n']),
27 3
            new \Twig_SimpleFilter('money_i18n_decimal', [$this->moneyFormatter, 'formatI18NDecimal']),
28 3
            new \Twig_SimpleFilter('money_currency_symbol', [$this->moneyFormatter, 'formatCurrencyAsSymbol']),
29 3
            new \Twig_SimpleFilter('money_currency_name', [$this->moneyFormatter, 'formatCurrencyAsName']),
30
        ];
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName()
37
    {
38
        return 'ivoba_sebastian_money_extension';
39
    }
40
41
}
42