Completed
Push — master ( 1dbff4...f4f5d5 )
by Bukashk0zzz
02:20
created

JmsSerializeContextGenerator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 11

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
c 1
b 1
f 0
lcom 0
cbo 11
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateContext() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the Bukashk0zzzLiipImagineSerializationBundle
5
 *
6
 * (c) Denis Golubovskiy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bukashk0zzz\LiipImagineSerializationBundle\Tests\EventListener;
13
14
use Doctrine\Common\Annotations\AnnotationReader;
15
use JMS\Serializer\Construction\UnserializeObjectConstructor;
16
use JMS\Serializer\Handler\HandlerRegistry;
17
use JMS\Serializer\Metadata\Driver\AnnotationDriver;
18
use JMS\Serializer\DeserializationContext;
19
use JMS\Serializer\GraphNavigator;
20
use JMS\Serializer\JsonSerializationVisitor;
21
use JMS\Serializer\Naming\CamelCaseNamingStrategy;
22
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
23
use Metadata\MetadataFactory;
24
use JMS\Serializer\EventDispatcher\EventDispatcher;
25
26
/**
27
 * JmsSerializeContextGenerator
28
 *
29
 * @author Denis Golubovskiy <[email protected]>
30
 */
31
class JmsSerializeContextGenerator
32
{
33
    /**
34
     * Generate JMS context
35
     * @return DeserializationContext
36
     */
37
    public function generateContext()
38
    {
39
        $namingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
40
41
        $context = DeserializationContext::create();
42
        $factory = new MetadataFactory(new AnnotationDriver(new AnnotationReader()));
43
        $context->initialize('json', new JsonSerializationVisitor($namingStrategy), new GraphNavigator($factory, new HandlerRegistry(), new UnserializeObjectConstructor(), new EventDispatcher()), $factory);
44
45
        return $context;
46
    }
47
}
48