Completed
Push — master ( fbc1fa...9bba21 )
by
unknown
14s
created

ModelToElasticaIdentifierTransformer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 17
ccs 0
cts 5
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
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 FOS\ElasticaBundle\Transformer;
13
14
use Elastica\Document;
15
16
/**
17
 * Creates an Elastica document with the ID of
18
 * the Doctrine object as Elastica document ID.
19
 */
20
class ModelToElasticaIdentifierTransformer extends ModelToElasticaAutoTransformer
21
{
22
    /**
23
     * Creates an elastica document with the id of the doctrine object as id.
24
     *
25
     * @param object $object the object to convert
26
     * @param array  $fields the keys we want to have in the returned array
27
     *
28
     * @return Document
29
     **/
30
    public function transform($object, array $fields)
31
    {
32
        $identifier = $this->propertyAccessor->getValue($object, $this->options['identifier']);
33
34
        return new Document($identifier);
35
    }
36
}
37