ServiceTrait::deserializeResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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