ModelToElasticaIdentifierTransformer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

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 <https://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 8
    public function transform(object $object, array $fields): Document
26
    {
27 8
        $identifier = $this->propertyAccessor->getValue($object, $this->options['identifier']);
28
29 8
        return new Document($identifier);
30
    }
31
}
32