Json::toArray()   A
last analyzed

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