Completed
Push — master ( 39762b...5dff0a )
by Samuel
12s queued 11s
created

SerializerBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 7
dl 0
loc 18
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

1 Method

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