ViewHandler::getSerializationContext()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
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