BasicFormatter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 11 3
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
 * BasicFormatter
16
 *
17
 * @package aura/intl
18
 *
19
 */
20
class BasicFormatter implements FormatterInterface
21
{
22
    /**
23
     *
24
     * Format message
25
     *
26
     * @param string $locale
27
     *
28
     * @param string $string
29
     *
30
     * @param array $tokens_values
31
     *
32
     * @return string A string replaced with the token values
33
     *
34
     */
35 1
    public function format($locale, $string, array $tokens_values)
36
    {
37 1
        $replace = [];
38 1
        foreach ($tokens_values as $token => $value) {
39
            // convert an array to a CSV string
40 1
            if (is_array($value)) {
41 1
                $value = '"' . implode('", "', $value) . '"';
42
            }
43 1
            $replace['{' . $token . '}'] = $value;
44
        }
45 1
        return strtr($string, $replace);
46
    }
47
}
48