Code Duplication    Length = 11-15 lines in 6 locations

src/Search/Sort/AbstractSort.php 1 location

@@ 108-118 (lines=11) @@
105
     * @param string $order
106
     * @throws InvalidArgument
107
     */
108
    protected function assertOrder($order)
109
    {
110
        $validOrders = [self::ORDER_ASC, self::ORDER_DESC];
111
        if (!in_array($order, $validOrders)) {
112
            throw new InvalidArgument(sprintf(
113
                'Sort `order` must be one of "%s", "%s" given.',
114
                implode(', ', $validOrders),
115
                $order
116
            ));
117
        }
118
    }
119
120
121
    /**

src/Search/Query/FullText/MatchQuery.php 3 locations

@@ 271-281 (lines=11) @@
268
     * @param string $operator
269
     * @throws InvalidArgument
270
     */
271
    protected function assertOperator($operator)
272
    {
273
        $validOperators = [self::OPERATOR_AND, self::OPERATOR_OR];
274
        if (!in_array($operator, $validOperators)) {
275
            throw new InvalidArgument(sprintf(
276
                'Match Query `operator` must be one of "%s", "%s" given.',
277
                implode(', ', $validOperators),
278
                $operator
279
            ));
280
        }
281
    }
282
283
284
    /**
@@ 288-298 (lines=11) @@
285
     * @param string $zeroTermsQuery
286
     * @throws InvalidArgument
287
     */
288
    protected function assertZeroTermsQuery($zeroTermsQuery)
289
    {
290
        $validZeroTermQueries = [self::ZERO_TERM_QUERY_NONE, self::ZERO_TERM_QUERY_ALL];
291
        if (!in_array($zeroTermsQuery, $validZeroTermQueries)) {
292
            throw new InvalidArgument(sprintf(
293
                'Match Query `zero_terms_query` must be one of "%s", "%s" given.',
294
                implode(', ', $validZeroTermQueries),
295
                $zeroTermsQuery
296
            ));
297
        }
298
    }
299
300
301
    /**
@@ 320-330 (lines=11) @@
317
     * @param string $type
318
     * @throws InvalidArgument
319
     */
320
    protected function assertType($type)
321
    {
322
        $validTypes = [self::TYPE_PHRASE, self::TYPE_PHRASE_PREFIX];
323
        if (!in_array($type, $validTypes)) {
324
            throw new InvalidArgument(sprintf(
325
                'Match Query `type` must be one of "%s", "%s" given.',
326
                implode(', ', $validTypes),
327
                $type
328
            ));
329
        }
330
    }
331
332
333
    /**

src/Search/Query/Geo/GeoDistanceQuery.php 1 location

@@ 143-153 (lines=11) @@
140
     * @param string $distanceType
141
     * @throws InvalidArgument
142
     */
143
    protected function assertDistanceType($distanceType)
144
    {
145
        $validTypes = [self::DISTANCE_TYPE_SLOPPY_ARC, self::DISTANCE_TYPE_ARC, self::DISTANCE_TYPE_PLANE];
146
        if (!in_array($distanceType, $validTypes)) {
147
            throw new InvalidArgument(sprintf(
148
                'GeoDistance Query `distance_type` must be one of "%s", "%s" given.',
149
                implode(', ', $validTypes),
150
                $distanceType
151
            ));
152
        }
153
    }
154
}
155

src/Search/Scoring/Functions/DecayScoringFunction.php 1 location

@@ 183-197 (lines=15) @@
180
     * @param string $decayFunction
181
     * @throws InvalidArgument
182
     */
183
    protected function assertDecayFunction($decayFunction)
184
    {
185
        $validFunctions = [
186
            self::DECAY_FUNCTION_LINEAR,
187
            self::DECAY_FUNCTION_EXPONENTIAL,
188
            self::DECAY_FUNCTION_GAUSSIAN,
189
        ];
190
        if (!in_array($decayFunction, $validFunctions)) {
191
            throw new InvalidArgument(sprintf(
192
                'DecayScoringFunction `decay_function` must be one of "%s", "%s" given.',
193
                implode(', ', $validFunctions),
194
                $decayFunction
195
            ));
196
        }
197
    }
198
}
199