ElasticaToModelTransformer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findByIdentifiers() 0 12 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\Doctrine\MongoDB;
13
14
use FOS\ElasticaBundle\Doctrine\AbstractElasticaToModelTransformer;
15
16
/**
17
 * Maps Elastica documents with Doctrine objects
18
 * This mapper assumes an exact match between
19
 * elastica documents ids and doctrine object ids.
20
 */
21
class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
22
{
23
    /**
24
     * Fetch objects for theses identifier values.
25
     *
26
     * @param array $identifierValues ids values
27
     * @param bool  $hydrate          whether or not to hydrate the objects, false returns arrays
28
     *
29
     * @return array of objects or arrays
30
     */
31
    protected function findByIdentifiers(array $identifierValues, $hydrate)
32
    {
33
        return $this->registry
34
            ->getManagerForClass($this->objectClass)
35
            ->getRepository($this->objectClass)
36
            ->{$this->options['query_builder_method']}($this->objectClass)
37
            ->field($this->options['identifier'])->in($identifierValues)
38
            ->hydrate($hydrate)
39
            ->getQuery()
40
            ->execute()
41
            ->toArray();
42
    }
43
}
44