Code Duplication    Length = 12-15 lines in 2 locations

src/Aggregation/Bucketing/DateRangeAggregation.php 1 location

@@ 45-56 (lines=12) @@
42
     * @param string $format
43
     * @param array  $ranges
44
     */
45
    public function __construct($name, $field = null, $format = null, array $ranges = [])
46
    {
47
        parent::__construct($name);
48
49
        $this->setField($field);
50
        $this->setFormat($format);
51
        foreach ($ranges as $range) {
52
            $from = isset($range['from']) ? $range['from'] : null;
53
            $to = isset($range['to']) ? $range['to'] : null;
54
            $this->addRange($from, $to);
55
        }
56
    }
57
58
    /**
59
     * @param string $format

src/Aggregation/Bucketing/Ipv4RangeAggregation.php 1 location

@@ 38-52 (lines=15) @@
35
     * @param string $field
36
     * @param array  $ranges
37
     */
38
    public function __construct($name, $field = null, $ranges = [])
39
    {
40
        parent::__construct($name);
41
42
        $this->setField($field);
43
        foreach ($ranges as $range) {
44
            if (is_array($range)) {
45
                $from = isset($range['from']) ? $range['from'] : null;
46
                $to = isset($range['to']) ? $range['to'] : null;
47
                $this->addRange($from, $to);
48
            } else {
49
                $this->addMask($range);
50
            }
51
        }
52
    }
53
54
    /**
55
     * Add range to aggregation.