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

SerializerBuilder::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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