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

Yaml::toVOArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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