Passed
Push — master ( e7b936...802caf )
by
unknown
06:49 queued 04:45
created

SimpleMessageFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Translator;
6
7
class SimpleMessageFormatter implements MessageFormatterInterface
8
{
9 3
    public function format(string $message, array $parameters, string $locale): string
10
    {
11 3
        $replacements = [];
12
        /** @var mixed $value */
13 3
        foreach ($parameters as $key => $value) {
14 3
            if (is_scalar($value)) {
15 2
                $replacements['{' . $key . '}'] = $value;
16
            }
17
        }
18 3
        return strtr($message, $replacements);
19
    }
20
}
21