Completed
Push — EZP-31287 ( fe8c5c...af9523 )
by
unknown
34:01
created

SimplifiedRequestNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 12 1
A supportsNormalization() 0 4 1
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 eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest;
10
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
11
12
final class SimplifiedRequestNormalizer extends PropertyNormalizer
13
{
14
    /**
15
     * @see \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize
16
     *
17
     * @param \eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest $object
18
     */
19
    public function normalize($object, $format = null, array $context = [])
20
    {
21
        return [
22
            'scheme' => $object->scheme,
23
            'host' => $object->host,
24
            'port' => $object->port,
25
            'pathinfo' => $object->pathinfo,
26
            'queryParams' => $object->queryParams,
27
            'languages' => $object->languages,
28
            'headers' => [],
29
        ];
30
    }
31
32
    public function supportsNormalization($data, $format = null, array $context = [])
33
    {
34
        return $data instanceof SimplifiedRequest;
35
    }
36
}
37