DateTimeSerializer::unserialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 14
loc 14
rs 9.4286
cc 1
eloc 8
nc 1
nop 3
1
<?php
2
3
/**
4
 * Author: Nil Portugués Calderó <[email protected]>
5
 * Date: 7/3/15
6
 * Time: 6:00 PM.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace NilPortugues\Serializer\Serializer\HHVM;
12
13
use NilPortugues\Serializer\Serializer;
14
use NilPortugues\Serializer\Serializer\InternalClasses\DateTimeZoneSerializer;
15
use ReflectionClass;
16
17 View Code Duplication
final class DateTimeSerializer
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    /**
20
     * @param Serializer $serializer
21
     * @param string     $className
22
     * @param array      $value
23
     *
24
     * @return object
25
     */
26
    public static function unserialize(Serializer $serializer, $className, array $value)
27
    {
28
        $dateTimeZone = DateTimeZoneSerializer::unserialize(
29
            $serializer,
30
            'DateTimeZone',
31
            array($serializer->unserialize($value['timezone']))
32
        );
33
34
        $ref = new ReflectionClass($className);
35
36
        return $ref->newInstanceArgs(
37
            array($serializer->unserialize($value['date']), $dateTimeZone)
38
        );
39
    }
40
}
41