Completed
Push — master ( 50437b...6d2b5a )
by Adam
02:31
created

Json::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
2
3
namespace BestServedCold\PhalueObjects\Format;
4
5
use BestServedCold\PhalueObjects\Contract\VOArrayable;
6
use BestServedCold\PhalueObjects\VOString;
7
use BestServedCold\PhalueObjects\VOArray\Mixin as VOArrayMixin;
8
9
/**
10
 * Class Json
11
 *
12
 * @package BestServedCold\PhalueObjects\Format
13
 */
14
class Json extends VOString implements VOArrayable
15
{
16
    use VOArrayMixin;
17
18
    /**
19
     * @return array
20
     */
21 2
    public function toArray()
22
    {
23 2
        return (array) json_decode($this->getValue(), true);
24
    }
25
26
    /**
27
     * @param  array  $array
28
     * @return static
29
     */
30 3
    public static function fromArray(array $array)
31
    {
32 3
        return new static(json_encode($array));
33
    }
34
}
35