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

UpperCaseWordsFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A format() 0 3 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 UpperCaseWordsFormatter
17
 *
18
 * @author  Dan McAdams
19
 * @package RoadBunch\Csv\Formatter
20
 */
21
class UpperCaseWordsFormatter implements FormatterInterface
22
{
23
    /** @var FormatterInterface */
24
    protected $formatter;
25
26
    /**
27
     * UpperCaseWordsFormatter constructor.
28
     */
29
    public function __construct()
30
    {
31 3
        $ucaseWords = function($var) {
32 2
            $del = [" ", "-", "_", "."];
33 2
            return ucwords($var, implode('', $del));
34 3
        };
35 3
        $this->formatter = new Formatter($ucaseWords);
36 3
    }
37
38
    /**
39
     * @param array $data
40
     *
41
     * @return array
42
     */
43 2
    public function format(array $data): array
44
    {
45 2
        return $this->formatter->format($data);
46
    }
47
}
48