DeepCopySerializer::serializeObject()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 14
rs 9.4286
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
/**
4
 * Author: Nil Portugués Calderó <[email protected]>
5
 * Date: 8/28/15
6
 * Time: 1:44 AM.
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;
12
13
use ReflectionClass;
14
15
class DeepCopySerializer extends Serializer
16
{
17
    /**
18
     * Extract the data from an object.
19
     *
20
     * @param mixed $value
21
     *
22
     * @return array
23
     */
24
    protected function serializeObject($value)
25
    {
26
        if (self::$objectStorage->contains($value)) {
27
            return self::$objectStorage[$value];
28
        }
29
30
        $reflection = new ReflectionClass($value);
31
        $className = $reflection->getName();
0 ignored issues
show
Bug introduced by
Consider using $reflection->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
32
33
        $serialized = $this->serializeInternalClass($value, $className, $reflection);
34
        self::$objectStorage->attach($value, $serialized);
35
36
        return $serialized;
37
    }
38
}
39