Passed
Push — master ( b32226...446c00 )
by Chris
08:06
created

ArrayToStringDataFormatter::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebTheory\Saveyour\Formatters;
4
5
use WebTheory\Saveyour\Contracts\DataFormatterInterface;
6
7
class ArrayToStringDataFormatter implements DataFormatterInterface
8
{
9
    /**
10
     *
11
     */
12
    protected $delimiter = ', ';
13
14
    /**
15
     *
16
     */
17 15
    public function __construct(?string $delimiter = null)
18
    {
19 15
        $delimiter && $this->delimiter = $delimiter;
20 15
    }
21
22
    /**
23
     *
24
     */
25 6
    public function formatData($value)
26
    {
27 6
        return implode($this->delimiter, $value);
28
    }
29
30
    /**
31
     *
32
     */
33 6
    public function formatInput($value)
34
    {
35 6
        return explode($this->delimiter, $value);
36
    }
37
}
38