ArrayToListDataFormatter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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