Completed
Pull Request — master (#220)
by
unknown
64:24
created

DateRange::preProcessSearch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 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\FilterManagerBundle\Filter\Widget\Range;
13
14
use ONGR\ElasticsearchBundle\Result\DocumentIterator;
15
use ONGR\FilterManagerBundle\Filter\ViewData;
16
use ONGR\FilterManagerBundle\Filter\ViewData\RangeAwareViewData;
17
18
/**
19
 * Date range filter, selects documents from lower date to upper date.
20
 */
21
class DateRange extends Range
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getViewData(DocumentIterator $result, ViewData $data)
27
    {
28
        $name = $data->getState()->getName();
29
30 View Code Duplication
        if (!$agg = $result->getAggregation($name)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
            $agg = $result->getAggregation($name . '-filter')->getAggregation($name);
0 ignored issues
show
Bug introduced by
The method getAggregation cannot be called on $result->getAggregation($name . '-filter') (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
32
        }
33
        /** @var $data RangeAwareViewData */
34
        $data->setMinBounds(
35
            new \DateTime('@' . (int) ($agg['min'] / 1000))
36
        );
37
38
        $data->setMaxBounds(
39
            new \DateTime('@' . (int) ($agg['max'] / 1000))
40
        );
41
42
        return $data;
43
    }
44
}
45