Code Duplication    Length = 13-16 lines in 3 locations

src/ORM/ListDecorator.php 1 location

@@ 230-242 (lines=13) @@
227
     * @param callable $callback
228
     * @return ArrayList (this may change in future implementations)
229
     */
230
    public function filterByCallback($callback)
231
    {
232
        if (!is_callable($callback)) {
233
            throw new LogicException(sprintf(
234
                "SS_Filterable::filterByCallback() passed callback must be callable, '%s' given",
235
                gettype($callback)
236
            ));
237
        }
238
        $output = ArrayList::create();
239
        foreach ($this->list as $item) {
240
            if (call_user_func($callback, $item, $this->list)) {
241
                $output->push($item);
242
            }
243
        }
244
        return $output;
245
    }

src/ORM/ArrayList.php 1 location

@@ 675-690 (lines=16) @@
672
     * @param callable $callback
673
     * @return ArrayList
674
     */
675
    public function filterByCallback($callback)
676
    {
677
        if (!is_callable($callback)) {
678
            throw new LogicException(sprintf(
679
                "SS_Filterable::filterByCallback() passed callback must be callable, '%s' given",
680
                gettype($callback)
681
            ));
682
        }
683
684
        $output = static::create();
685
686
        foreach ($this as $item) {
687
            if (call_user_func($callback, $item, $this)) {
688
                $output->push($item);
689
            }
690
        }
691
692
        return $output;
693
    }

src/ORM/DataList.php 1 location

@@ 489-504 (lines=16) @@
486
     * @param callable $callback
487
     * @return ArrayList (this may change in future implementations)
488
     */
489
    public function filterByCallback($callback)
490
    {
491
        if (!is_callable($callback)) {
492
            throw new LogicException(sprintf(
493
                "SS_Filterable::filterByCallback() passed callback must be callable, '%s' given",
494
                gettype($callback)
495
            ));
496
        }
497
        /** @var ArrayList $output */
498
        $output = ArrayList::create();
499
        foreach ($this as $item) {
500
            if (call_user_func($callback, $item, $this)) {
501
                $output->push($item);
502
            }
503
        }
504
        return $output;
505
    }
506
507
    /**