Passed
Push — feature/v4 ( e5e380...dac4aa )
by Samuel
11:37
created

SerializerBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 13
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Ivory Google Map package.
7
 *
8
 * (c) Eric GELOEN <[email protected]>
9
 *
10
 * For the full copyright and license information, please read the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ivory\GoogleMap\Service\Serializer;
15
16
use Ivory\Serializer\Mapping\Factory\CacheClassMetadataFactory;
17
use Ivory\Serializer\Mapping\Factory\ClassMetadataFactory;
18
use Ivory\Serializer\Mapping\Loader\DirectoryClassMetadataLoader;
19
use Ivory\Serializer\Navigator\Navigator;
20
use Ivory\Serializer\Registry\TypeRegistry;
21
use Ivory\Serializer\Serializer;
22
use Ivory\Serializer\Type\ObjectType;
23
use Ivory\Serializer\Type\Type;
24
use Psr\Cache\CacheItemPoolInterface;
25
26
class SerializerBuilder
27
{
28
    /** @return Serializer */
29
    public static function create(CacheItemPoolInterface $pool = null)
30
    {
31
        $classMetadataFactory = new ClassMetadataFactory(new DirectoryClassMetadataLoader(__DIR__));
32
33
        if (null !== $pool) {
34
            $classMetadataFactory = new CacheClassMetadataFactory($classMetadataFactory, $pool);
35
        }
36
37
        return new Serializer(new Navigator(TypeRegistry::create([
38
            Type::OBJECT => new ObjectType($classMetadataFactory),
39
        ])));
40
    }
41
}
42