Completed
Push — 6.13 ( 7401a7...8452de )
by
unknown
18:35
created

SerializerTrait::getSerializer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer;
8
9
use Symfony\Component\Serializer\Encoder\JsonEncoder;
10
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
11
use Symfony\Component\Serializer\Serializer;
12
13
trait SerializerTrait
14
{
15
    /**
16
     * @return \Symfony\Component\Serializer\SerializerInterface
17
     */
18
    public function getSerializer()
19
    {
20
        return new Serializer(
21
            [(new PropertyNormalizer())->setIgnoredAttributes(['request'])],
22
            [new JsonEncoder()]
23
        );
24
    }
25
}
26