Completed
Push — master ( bd2156...bea8fa )
by Simonas
11s
created

ArrayIterator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A convertDocument() 0 10 3
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