ServiceTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 8
c 2
b 0
f 1
dl 0
loc 23
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A deserializeResponse() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Etrias\EwarehousingConnector\Serializer;
14
15
use JMS\Serializer\DeserializationContext;
16
use JMS\Serializer\SerializerInterface;
17
use Psr\Http\Message\ResponseInterface;
18
19
trait ServiceTrait
20
{
21
    /**
22
     * @var SerializerInterface
23
     */
24
    protected $serializer;
25
26
    /**
27
     * @param ResponseInterface      $response
28
     * @param string                 $className
29
     * @param DeserializationContext $context
30
     *
31
     * @return mixed
32
     */
33
    protected function deserializeResponse(ResponseInterface $response, $className, DeserializationContext $context = null)
34
    {
35
        $content = (string) $response->getBody();
36
37
        return $this->serializer->deserialize(
38
            $content,
39
            $className,
40
            'json',
41
            $context
42
        );
43
    }
44
}
45