Code Duplication    Length = 12-12 lines in 3 locations

src/Collection.php 3 locations

@@ 106-117 (lines=12) @@
103
     * @param string|callable $fn '$_ > 100'
104
     * @return $this
105
     */
106
    public function filter($fn)
107
    {
108
        $this->is_array = false;
109
        if (is_callable($fn)) {
110
            $fn_name = '_fn' . $this->fn_cnt++;
111
            $this->vars[$fn_name] = $fn;
112
            $this->ops[] = '    if (!$' . $fn_name . '($_)) continue;';
113
        } else {
114
            $this->ops[] = '    if (!(' . $fn . ')) continue;';
115
        }
116
        return $this->step();
117
    }
118
119
    /**
120
     * @param string|callable $fn '$_ > 100'
@@ 123-134 (lines=12) @@
120
     * @param string|callable $fn '$_ > 100'
121
     * @return $this
122
     */
123
    public function reject($fn)
124
    {
125
        $this->is_array = false;
126
        if (is_callable($fn)) {
127
            $fn_name = '_fn' . $this->fn_cnt++;
128
            $this->vars[$fn_name] = $fn;
129
            $this->ops[] = '    if ($' . $fn_name . '($_)) continue;';
130
        } else {
131
            $this->ops[] = '    if (' . $fn . ') continue;';
132
        }
133
        return $this->step();
134
    }
135
136
    /**
137
     * @param string|callable $fn '$_ * 2'
@@ 140-151 (lines=12) @@
137
     * @param string|callable $fn '$_ * 2'
138
     * @return $this
139
     */
140
    public function map($fn)
141
    {
142
        $this->is_array = false;
143
        if (is_callable($fn)) {
144
            $fn_name = '_fn' . $this->fn_cnt++;
145
            $this->vars[$fn_name] = $fn;
146
            $this->ops[] = '    $_ = $' . $fn_name . '($_);';
147
        } else {
148
            $this->ops[] = '    $_ = ' . $fn . ';';
149
        }
150
        return $this->step();
151
    }
152
153
    /**
154
     * @param string[] column