Code Duplication    Length = 13-14 lines in 2 locations

src/Aggregation/Bucketing/DateRangeAggregation.php 1 location

@@ 48-61 (lines=14) @@
45
     * @param array  $ranges
46
     * @param bool   $keyed
47
     */
48
    public function __construct($name, $field = null, $format = null, array $ranges = [], $keyed = false)
49
    {
50
        parent::__construct($name);
51
52
        $this->setField($field);
53
        $this->setFormat($format);
54
        $this->setKeyed($keyed);
55
        foreach ($ranges as $range) {
56
            $from = isset($range['from']) ? $range['from'] : null;
57
            $to = isset($range['to']) ? $range['to'] : null;
58
            $key = isset($range['key']) ? $range['key'] : null;
59
            $this->addRange($from, $to, $key);
60
        }
61
    }
62
63
    /**
64
     * Sets if result buckets should be keyed.

src/Aggregation/Bucketing/RangeAggregation.php 1 location

@@ 44-56 (lines=13) @@
41
     * @param array  $ranges
42
     * @param bool   $keyed
43
     */
44
    public function __construct($name, $field = null, $ranges = [], $keyed = false)
45
    {
46
        parent::__construct($name);
47
48
        $this->setField($field);
49
        $this->setKeyed($keyed);
50
        foreach ($ranges as $range) {
51
            $from = isset($range['from']) ? $range['from'] : null;
52
            $to = isset($range['to']) ? $range['to'] : null;
53
            $key = isset($range['key']) ? $range['key'] : null;
54
            $this->addRange($from, $to, $key);
55
        }
56
    }
57
58
    /**
59
     * Sets if result buckets should be keyed.