ViewHandler::setSerializerEnableMaxDepthChecks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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