Code Duplication    Length = 8-13 lines in 3 locations

src/Collection.php 3 locations

@@ 192-199 (lines=8) @@
189
    /**
190
     * @return int|float
191
     */
192
    public function sum()
193
    {
194
        $ops = $this->ops;
195
        $before = '$_result = 0;';
196
        $ops[] = '$_result += $_;';
197
198
        return self::evaluate($this->seed, $this->vars, $this->compile($ops), $before, '');
199
    }
200
201
    /**
202
     * @return int|float
@@ 204-211 (lines=8) @@
201
    /**
202
     * @return int|float
203
     */
204
    public function product()
205
    {
206
        $ops = $this->ops;
207
        $before = '$_result = 1;';
208
        $ops[] = '$_result *= $_;';
209
210
        return self::evaluate($this->seed, $this->vars, $this->compile($ops), $before, '');
211
    }
212
213
    /**
214
     * @return \Spindle\Collection (new instance)
@@ 246-258 (lines=13) @@
243
    /**
244
     * @return \Generator
245
     */
246
    public function getIterator()
247
    {
248
        $ops = $this->ops;
249
        $ops[] = 'yield $_key => $_;';
250
        $gen = self::evaluate(
251
            $this->seed,
252
            $this->vars,
253
            $this->compile($ops),
254
            '$_result = static function() use($_seed){',
255
            '};'
256
        );
257
        return $gen();
258
    }
259
260
    /**
261
     * @return array