ViewHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSerializerEnableMaxDepthChecks() 0 4 1
A setSerializerEnableMaxDepthChecks() 0 4 1
A getSerializationContext() 0 10 2
1
<?php
2
3
namespace DoS\ResourceBundle\Rest;
4
5
use FOS\RestBundle\View\View;
6
use FOS\RestBundle\View\ViewHandler as BaseViewHandler;
7
8
class ViewHandler extends BaseViewHandler
9
{
10
    protected $serializerEnableMaxDepthChecks = true;
11
12
    /**
13
     * @return bool
14
     */
15
    public function getSerializerEnableMaxDepthChecks()
16
    {
17
        $this->serializerEnableMaxDepthChecks;
18
    }
19
20
    /**
21
     * @param bool $flag
22
     */
23
    public function setSerializerEnableMaxDepthChecks($flag)
24
    {
25
        $this->serializerEnableMaxDepthChecks = boolval($flag);
26
    }
27
28
    /**
29
     * @param View $view
30
     *
31
     * @return \JMS\Serializer\SerializationContext
32
     */
33
    protected function getSerializationContext(View $view)
34
    {
35
        $context = parent::getSerializationContext($view);
36
37
        if ($this->serializerEnableMaxDepthChecks) {
38
            $context->enableMaxDepthChecks();
39
        }
40
41
        return $context;
42
    }
43
}
44