Passed
Push — master ( 955c83...94d693 )
by Alexander
02:18
created

Formatter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 14 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator;
6
7
class Formatter implements FormatterInterface
8
{
9 168
    public function format(string $message, array $parameters = []): string
10
    {
11 168
        $replacements = [];
12 168
        foreach ($parameters as $key => $value) {
13 71
            if (is_array($value)) {
14 1
                $value = 'array';
15 70
            } elseif (is_object($value)) {
16 2
                $value = 'object';
17 68
            } elseif (is_resource($value)) {
18 1
                $value = 'resource';
19
            }
20 71
            $replacements['{' . $key . '}'] = $value;
21
        }
22 168
        return strtr($message, $replacements);
23
    }
24
}
25