N2WExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFilters() 0 7 1
1
<?php
2
/**
3
 * @link https://github.com/phpviet/symfony-number-to-words
4
 *
5
 * @copyright (c) PHP Viet
6
 * @license [MIT](https://opensource.org/licenses/MIT)
7
 */
8
9
namespace PHPViet\Symfony\NumberToWords\Twig\Extension;
10
11
use Twig\TwigFilter;
12
use Twig\Extension\AbstractExtension;
13
use PHPViet\Symfony\NumberToWords\Service;
14
15
/**
16
 * @author Vuong Minh <[email protected]>
17
 * @since 1.0.0
18
 */
19
class N2WExtension extends AbstractExtension
20
{
21
    /**
22
     * Phone number helper.
23
     *
24
     * @var Service
25
     */
26
    protected $service;
27
28
    /**
29
     * Khởi tạo extension.
30
     *
31
     * @param Service $service
32
     */
33
    public function __construct(Service $service)
34
    {
35
        $this->service = $service;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getFilters(): array
42
    {
43
        return [
44
            new TwigFilter('n2w', [$this->service, 'toWords']),
45
            new TwigFilter('n2c', [$this->service, 'toCurrency']),
46
        ];
47
    }
48
}
49