ArrayToListDataFormatter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A formatInput() 0 3 1
A formatData() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace WebTheory\Saveyour\Formatting;
4
5
use WebTheory\Saveyour\Contracts\Formatting\DataFormatterInterface;
6
7
class ArrayToListDataFormatter implements DataFormatterInterface
8
{
9
    protected string $delimiter = ', ';
10
11 6
    public function __construct(?string $delimiter = null)
12
    {
13 6
        $this->delimiter = $delimiter ?? $this->delimiter;
14
    }
15
16 3
    public function formatData($value)
17
    {
18 3
        return implode($this->delimiter, $value);
19
    }
20
21 3
    public function formatInput($value)
22
    {
23 3
        return explode($this->delimiter, $value);
24
    }
25
}
26