Completed
Pull Request — master (#678)
by Simonas
02:54 queued 13s
created

ArrayIterator::convertDocument()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 6
nc 3
nop 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\Result;
13
14
use ONGR\ElasticsearchBundle\Result\Aggregation\AggregationValue;
15
use ONGR\ElasticsearchBundle\Service\Manager;
16
17
/**
18
 * Class DocumentIterator.
19
 */
20
class ArrayIterator extends AbstractResultsIterator
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function convertDocument(array $document)
26
    {
27
        if (array_key_exists('_source', $document)) {
28
            return $document['_source'];
29
        } elseif (array_key_exists('fields', $document)) {
30
            return array_map('reset', $document['fields']);
31
        }
32
33
        return $document;
34
    }
35
}
36