Passed
Push — master ( b6cc98...f3d222 )
by Agaletskiy
01:51
created

SymfonySerializerAdapterFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 7
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\OmsClient\Impl\Serializer;
6
7
use Doctrine\Common\Annotations\AnnotationReader;
8
use Lamoda\OmsClient\Serializer\SerializerInterface;
9
use Symfony\Component\Serializer\Encoder\JsonEncoder;
10
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
11
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
12
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
13
use Symfony\Component\Serializer\Serializer;
14
15
final class SymfonySerializerAdapterFactory
16
{
17 1
    public static function create(): SerializerInterface
18
    {
19 1
        $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
20 1
        $normalizer = new ObjectNormalizer($classMetadataFactory);
21 1
        $encoder = new JsonEncoder();
22
23 1
        $symfonySerializer = new Serializer([$normalizer], [$encoder]);
24
25 1
        return new SymfonySerializerAdapter($symfonySerializer);
26
    }
27
}
28