HalJsonSerializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 9
Bugs 0 Features 1
Metric Value
wmc 3
c 9
b 0
f 1
lcom 0
cbo 2
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A serializeObject() 0 10 2
1
<?php
2
3
/**
4
 * Author: Nil Portugués Calderó <[email protected]>
5
 * Date: 8/16/15
6
 * Time: 4:43 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
12
namespace NilPortugues\Laravel5\HalJsonSerializer;
13
14
use ErrorException;
15
use Illuminate\Database\Eloquent\Model;
16
use NilPortugues\Api\HalJson\HalJsonTransformer;
17
use NilPortugues\Serializer\DeepCopySerializer;
18
use NilPortugues\Serializer\Drivers\Eloquent\EloquentDriver;
19
use ReflectionClass;
20
use ReflectionMethod;
21
22
/**
23
 * Class HalJsonSerializer.
24
 */
25
class HalJsonSerializer extends DeepCopySerializer
26
{
27
    /**
28
     * @param HalJsonTransformer $halJsonTransformer
29
     */
30
    public function __construct(HalJsonTransformer $halJsonTransformer)
31
    {
32
        parent::__construct($halJsonTransformer);
33
    }
34
35
    /**
36
     * Extract the data from an object.
37
     *
38
     * @param mixed $value
39
     *
40
     * @return array
41
     */
42
    protected function serializeObject($value)
43
    {
44
45
        $serialized = EloquentDriver::serialize($value);
46
        if ($value !== $serialized) {
47
            return $serialized;
48
        }
49
50
        return parent::serializeObject($value);
51
    }
52
}
53