TranslatorFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 36
ccs 3
cts 3
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A newInstance() 0 8 1
1
<?php
2
/**
3
 *
4
 * This file is part of the Aura Project for PHP.
5
 *
6
 * @package aura/intl
7
 *
8
 * @license http://opensource.org/licenses/MIT MIT
9
 *
10
 */
11
namespace Aura\Intl;
12
13
/**
14
 *
15
 * Factory to create Translator objects.
16
 *
17
 * @package aura/intl
18
 *
19
 */
20
class TranslatorFactory
21
{
22
    /**
23
     *
24
     * The class to use for new instances.
25
     *
26
     * @var string
27
     *
28
     */
29
    protected $class = Translator::class;
30
31
    /**
32
     *
33
     * Returns a new Translator.
34
     *
35
     * @param string $locale The locale code for the translator.
36
     *
37
     * @param Package $package The localized package for the translator.
38
     *
39
     * @param FormatterInterface $formatter The formatter to use for
40
     * interpolating token values.
41
     *
42
     * @param TranslatorInterface $fallback A fallback translator to use, if
43
     * any.
44
     *
45
     * @return Translator
46
     *
47
     */
48 5
    public function newInstance(
49
        $locale,
50
        Package $package,
51
        FormatterInterface $formatter,
52
        TranslatorInterface $fallback = null
53
    ) {
54 5
        $class = $this->class;
55 5
        return new $class($locale, $package, $formatter, $fallback);
56
    }
57
}
58