Code Duplication    Length = 20-21 lines in 2 locations

src/Aggregation/Bucketing/GeoDistanceAggregation.php 1 location

@@ 129-148 (lines=20) @@
126
     *
127
     * @return GeoDistanceAggregation
128
     */
129
    public function addRange($from = null, $to = null)
130
    {
131
        $range = array_filter(
132
            [
133
                'from' => $from,
134
                'to' => $to,
135
            ],
136
            function ($v) {
137
                return !is_null($v);
138
            }
139
        );
140
141
        if (empty($range)) {
142
            throw new \LogicException('Either from or to must be set. Both cannot be null.');
143
        }
144
145
        $this->ranges[] = $range;
146
147
        return $this;
148
    }
149
150
    /**
151
     * {@inheritdoc}

src/Aggregation/Bucketing/DateRangeAggregation.php 1 location

@@ 104-124 (lines=21) @@
101
     *
102
     * @throws \LogicException
103
     */
104
    public function addRange($from = null, $to = null, $key = null)
105
    {
106
        $range = array_filter(
107
            [
108
                'from' => $from,
109
                'to' => $to,
110
                'key' => $key,
111
            ],
112
            function ($v) {
113
                return !is_null($v);
114
            }
115
        );
116
117
        if (empty($range)) {
118
            throw new \LogicException('Either from or to must be set. Both cannot be null.');
119
        }
120
121
        $this->ranges[] = $range;
122
123
        return $this;
124
    }
125
126
    /**
127
     * {@inheritdoc}