Passed
Push — master ( 14b05a...fa6902 )
by Daniel
02:41
created

UnderscoreToSpaceFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 3 1
A __construct() 0 4 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * This file is part of the Csv-Machine package.
5
 *
6
 * (c) Dan McAdams <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace RoadBunch\Csv\Formatter;
13
14
15
/**
16
 * Class UnderscoreToSpaceFormatter
17
 *
18
 * @author  Dan McAdams
19
 * @package RoadBunch\Csv\Formatter
20
 */
21
class UnderscoreToSpaceFormatter implements FormatterInterface
22
{
23
    /** @var FormatterInterface */
24
    protected $formatter;
25
26
    /**
27
     * UnderscoreToSpaceFormatter constructor.
28
     */
29
    public function __construct()
30
    {
31 3
        $this->formatter = new Formatter(function ($var) {
32 2
            return str_replace('_', ' ', $var);
33 3
        });
34 3
    }
35
36
    /**
37
     * @param array $data
38
     *
39
     * @return array
40
     */
41 2
    public function format(array $data): array
42
    {
43 2
        return $this->formatter->format($data);
44
    }
45
}
46