Completed
Pull Request — master (#4)
by
unknown
09:27
created

Transformer.php ➔ transformer()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
use PHPViet\NumberToWords\DictionaryInterface;
4
use PHPViet\NumberToWords\Transformer;
5
6
if (! function_exists('transformer')) {
7
8
    /**
9
     * Lấy transformer instance
10
     *
11
     * @param \PHPViet\NumberToWords\DictionaryInterface $dictionary
12
     * @return \PHPViet\NumberToWords\Transformer
13
     */
14
    function transformer(DictionaryInterface $dictionary = null)
15
    {
16
        static $transformer;
17
18
        if ($dictionary) {
19
            return new Transformer($dictionary);
20
        }
21
22
        if (! $transformer) {
23
            $transformer = new Transformer();
24
        }
25
26
        return $transformer;
27
    }
28
}