Completed
Push — 6.0-dev ( 1ef812...ceea66 )
by Simonas
01:30
created

Converter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A convertArrayToDocument() 0 4 1
A convertDocumentToArray() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\ElasticsearchBundle\Mapping;
13
14
use ONGR\ElasticsearchBundle\Annotation\NestedType;
15
use ONGR\ElasticsearchBundle\Annotation\ObjectType;
16
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
17
use Symfony\Component\Serializer\Serializer;
18
use Symfony\Component\Serializer\SerializerAwareTrait;
19
use Symfony\Component\Serializer\SerializerInterface;
20
21
/**
22
 * This class converts array to document object.
23
 */
24
class Converter
25
{
26
    use SerializerAwareTrait;
27
28
    private $documentParser;
29
30
    public function __construct(DocumentParser $documentParser)
31
    {
32
        $this->documentParser = $documentParser;
33
    }
34
35
    public function convertArrayToDocument(string $namespace, array $raw, Serializer $serializer)
36
    {
37
        return $serializer->denormalize($raw, $namespace);
38
    }
39
40
    public function convertDocumentToArray($document, Serializer $serializer): array
41
    {
42
        return $serializer->normalize($document, 'array');
43
    }
44
}
45