SymfonySerializerAdapter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 17
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 3 1
A __construct() 0 3 1
A deserialize() 0 3 1
1
<?php
2
/*
3
 * This file is part of JSON RPC Client.
4
 *
5
 * (c) Igor Lazarev <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Strider2038\JsonRpcClient\Bridge\Symfony\Serialization;
12
13
use Strider2038\JsonRpcClient\Response\ResponseObjectInterface;
14
use Strider2038\JsonRpcClient\Serialization\MessageSerializerInterface;
15
use Symfony\Component\Serializer\SerializerInterface;
16
17
/**
18
 * @author Igor Lazarev <[email protected]>
19
 */
20
class SymfonySerializerAdapter implements MessageSerializerInterface
21
{
22
    private SerializerInterface $serializer;
23
24
    public function __construct(SerializerInterface $serializer)
25 12
    {
26
        $this->serializer = $serializer;
27 12
    }
28 12
29
    public function serialize($request): string
30 5
    {
31
        return $this->serializer->serialize($request, 'json');
32 5
    }
33
34
    public function deserialize(string $response, array $context)
35 5
    {
36
        return $this->serializer->deserialize($response, ResponseObjectInterface::class, 'json', $context);
37 5
    }
38
}
39