ObjectSerializer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Enqueue\SimpleBus\Bridge\Symfony\Serializer;
6
7
use SimpleBus\Serialization\ObjectSerializer as ObjectSerializerInterface;
8
use Symfony\Component\Serializer\SerializerInterface;
9
10
class ObjectSerializer implements ObjectSerializerInterface
11
{
12
    private const FORMAT = 'json';
13
14
    private $serializer;
15
16
    public function __construct(SerializerInterface $serializer)
17
    {
18
        $this->serializer = $serializer;
19
    }
20
21
    public function serialize($object): string
22
    {
23
        return $this->serializer->serialize($object, self::FORMAT);
24
    }
25
26
    public function deserialize($serializedObject, $type)
27
    {
28
        return $this->serializer->deserialize($serializedObject, $type, self::FORMAT);
29
    }
30
}
31