Code Duplication    Length = 24-24 lines in 2 locations

src/Charcoal/Source/AbstractSource.php 2 locations

@@ 245-268 (lines=24) @@
242
     * @throws InvalidArgumentException If the $param argument is invalid.
243
     * @return self
244
     */
245
    public function addFilter($param, $value = null, array $options = null)
246
    {
247
        if (is_string($param) && $value !== null) {
248
            $expr = $this->createFilter();
249
            $expr->setProperty($param);
250
            $expr->setValue($value);
251
        } else {
252
            $expr = $param;
253
        }
254
255
        $expr = $this->processFilter($expr);
256
257
        /** @deprecated 0.3 */
258
        if (is_array($param) && isset($param['options'])) {
259
            $expr->setData($param['options']);
260
        }
261
262
        if (is_array($options)) {
263
            $expr->setData($options);
264
        }
265
266
        $this->filters[] = $this->parseFilterWithModel($expr);
267
        return $this;
268
    }
269
270
    /**
271
     * Process a query filter with the current model.
@@ 337-360 (lines=24) @@
334
     * @throws InvalidArgumentException If the $param argument is invalid.
335
     * @return self
336
     */
337
    public function addOrder($param, $mode = 'asc', array $options = null)
338
    {
339
        if (is_string($param) && $mode !== null) {
340
            $expr = $this->createOrder();
341
            $expr->setProperty($param);
342
            $expr->setMode($mode);
343
        } else {
344
            $expr = $param;
345
        }
346
347
        $expr = $this->processOrder($expr);
348
349
        /** @deprecated 0.3 */
350
        if (is_array($param) && isset($param['options'])) {
351
            $expr->setData($param['options']);
352
        }
353
354
        if (is_array($options)) {
355
            $expr->setData($options);
356
        }
357
358
        $this->orders[] = $this->parseOrderWithModel($expr);
359
        return $this;
360
    }
361
362
    /**
363
     * Process a query order with the current model.