Passed
Push — master ( 5de986...4c5faf )
by Chris
02:41
created

DelimitedArrayListFormatter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A formatData() 0 3 1
A formatInput() 0 3 1
A __construct() 0 3 2
1
<?php
2
3
namespace WebTheory\Saveyour\Formatters;
4
5
use WebTheory\Saveyour\Contracts\DataFormatterInterface;
6
7
class DelimitedArrayListFormatter implements DataFormatterInterface
8
{
9
    /**
10
     *
11
     */
12
    protected $delimiter = ', ';
13
14
    /**
15
     *
16
     */
17 6
    public function __construct(?string $delimiter = null)
18
    {
19 6
        $delimiter && $this->delimiter = $delimiter;
20 6
    }
21
22
    /**
23
     *
24
     */
25 3
    public function formatData($value)
26
    {
27 3
        return implode($this->delimiter, $value);
28
    }
29
30
    /**
31
     *
32
     */
33 3
    public function formatInput($value)
34
    {
35 3
        return explode($this->delimiter, $value);
36
    }
37
}
38