Code Duplication    Length = 12-12 lines in 3 locations

src/Collection.php 1 location

@@ 114-125 (lines=12) @@
111
     * @param string|callable $fn '$_ * 2'
112
     * @return $this
113
     */
114
    public function map($fn)
115
    {
116
        $this->is_array = false;
117
        if (is_callable($fn)) {
118
            $fn_name = '_fn' . $this->fn_cnt++;
119
            $this->vars[$fn_name] = $fn;
120
            $this->ops[] = '    $_ = $' . $fn_name . '($_);';
121
        } else {
122
            $this->ops[] = '    $_ = ' . $fn . ';';
123
        }
124
        return $this->step();
125
    }
126
127
    /**
128
     * @param string|string[] columns

src/Traits/LimitTrait.php 2 locations

@@ 10-21 (lines=12) @@
7
     * @param string|callable $fn '$_ > 100'
8
     * @return $this
9
     */
10
    public function filter($fn)
11
    {
12
        $this->is_array = false;
13
        if (is_callable($fn)) {
14
            $fn_name = '_fn' . $this->fn_cnt++;
15
            $this->vars[$fn_name] = $fn;
16
            $this->ops[] = '    if (!$' . $fn_name . '($_)) continue;';
17
        } else {
18
            $this->ops[] = '    if (!(' . $fn . ')) continue;';
19
        }
20
        return $this->step();
21
    }
22
23
    /**
24
     * @param string|callable $fn '$_ > 100'
@@ 27-38 (lines=12) @@
24
     * @param string|callable $fn '$_ > 100'
25
     * @return $this
26
     */
27
    public function reject($fn)
28
    {
29
        $this->is_array = false;
30
        if (is_callable($fn)) {
31
            $fn_name = '_fn' . $this->fn_cnt++;
32
            $this->vars[$fn_name] = $fn;
33
            $this->ops[] = '    if ($' . $fn_name . '($_)) continue;';
34
        } else {
35
            $this->ops[] = '    if (' . $fn . ') continue;';
36
        }
37
        return $this->step();
38
    }
39
40
    /**
41
     * @param int $offset