Passed
Push — master ( ce0bdd...5bd05b )
by
unknown
51s queued 12s
created

SymfonySerializer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Simple\Queue\Serializer;
6
7
use Symfony\Component\Serializer\Serializer;
8
use Symfony\Component\Serializer\Encoder\JsonEncoder;
9
10
/**
11
 * Class SymfonySerializer
12
 * @package Simple\Queue\Serializer
13
 */
14
class SymfonySerializer implements SerializerInterface
15
{
16
    /** @var Serializer */
17
    private Serializer $serializer;
18
19
    /**
20
     * SymfonySerializer constructor.
21
     */
22 1
    public function __construct()
23
    {
24 1
        $this->serializer = new Serializer([], [new JsonEncoder()]);
25 1
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30 1
    public function serialize($data): string
31
    {
32 1
        return $this->serializer->encode($data, JsonEncoder::FORMAT);
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38 1
    public function deserialize(string $data)
39
    {
40 1
        return $this->serializer->decode($data, JsonEncoder::FORMAT);
41
    }
42
}
43