Completed
Push — master ( a4e176...8c9478 )
by Adam
02:50
created

Csv   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 20
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Format;
4
5
use BestServedCold\PhalueObjects\Contract\Arrayable;
6
use BestServedCold\PhalueObjects\ValueObject;
7
8
/**
9
 * Class Csv
10
 *
11
 * @package BestServedCold\PhalueObjects\Format
12
 */
13
class Csv extends ValueObject implements Arrayable
14
{
15
    /**
16
     * @param  array       $array
17
     * @param  string|null $space
18
     * @return static
19
     */
20 12
    public static function fromArray(array $array, $space = null)
21
    {
22 12
        return new static(implode(',' . $space, $array));
23
    }
24
25
    /**
26
     * @return array
27
     */
28
    public function toArray()
29
    {
30
        return explode(',', $this->getValue());
31
    }
32
}
33