ArrayFormat::unserialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
namespace Thunder\Serializard\Format;
3
4
use Thunder\Serializard\Exception\UnserializationFailureException;
5
use Thunder\Serializard\HydratorContainer\HydratorContainerInterface as Hydrators;
6
use Thunder\Serializard\NormalizerContainer\NormalizerContainerInterface as Normalizers;
7
use Thunder\Serializard\NormalizerContext\NormalizerContextInterface;
8
9
/**
10
 * @author Tomasz Kowalczyk <[email protected]>
11
 */
12
final class ArrayFormat extends AbstractFormat
13
{
14 5
    public function serialize($var, Normalizers $normalizers, NormalizerContextInterface $context)
15
    {
16 5
        return $this->doSerialize($var, $normalizers, $context);
17
    }
18
19 3
    public function unserialize($var, $class, Hydrators $hydrators)
20
    {
21 3
        if(false === \is_array($var)) {
22 1
            throw new UnserializationFailureException('ArrayFormat can unserialize only arrays!');
23
        }
24
25 2
        return $this->doUnserialize($var, $class, $hydrators);
26
    }
27
}
28