Completed
Push — master ( 8c9478...0f7d17 )
by Adam
02:25
created

Yaml   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 36
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 4 1
A toVOArray() 0 4 1
A fromArray() 0 4 1
A fromVOArray() 0 4 1
1
<?php namespace
2
3
BestServedCold\PhalueObjects\Format;
4
5
use BestServedCold\PhalueObjects\Contract\Arrayable;
6
use BestServedCold\PhalueObjects\Contract\VOArrayable;
7
use BestServedCold\PhalueObjects\Format;
8
use BestServedCold\PhalueObjects\VOArray;
9
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
10
11
/**
12
 * Class Yaml
13
 *
14
 * @package BestServedCold\PhalueObjects\File
15
 */
16
class Yaml extends Format implements Arrayable, VOArrayable
17
{
18
    /**
19
     * @return array
20
     */
21 2
    public function toArray()
22
    {
23 2
        return (array) SymfonyYaml::parse($this->getValue());
24
    }
25
26
    /**
27
     * @return VOArray
28
     */
29 1
    public function toVOArray()
30
    {
31 1
        return VOArray::fromArray(self::toArray());
32
    }
33
34
    /**
35
     * @param  array  $array
36
     * @return static
37
     */
38 2
    public static function fromArray(array $array)
39
    {
40 2
        return new static(SymfonyYaml::dump($array));
41
    }
42
43
    /**
44
     * @param  VOArray $voArray
45
     * @return Yaml
46
     */
47 1
    public static function fromVOArray(VOArray $voArray)
48
    {
49 1
        return self::fromArray($voArray->getValue());
50
    }
51
}
52