Code Duplication    Length = 11-12 lines in 3 locations

src/Zicht/Itertools/twig/Extension.php 3 locations

@@ 217-227 (lines=11) @@
214
     * @return \Closure
215
     * @throws \InvalidArgumentException
216
     */
217
    public function reducing($name)
218
    {
219
        // note, once we stop supporting php 5.5, we can rewrite the code below
220
        // to the reducing($name, ...$args) structure.
221
        // http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list
222
        $method = sprintf('\Zicht\Itertools\util\Reductions::%s', $name);
223
        if (!is_callable($method)) {
224
            throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid reduction.', $name));
225
        }
226
        return call_user_func_array($method, array_slice(func_get_args(), 1));
227
    }
228
229
    /**
230
     * Returns a mapping closure
@@ 239-249 (lines=11) @@
236
     * @return \Closure
237
     * @throws \InvalidArgumentException
238
     */
239
    public function mapping($name)
240
    {
241
        // note, once we stop supporting php 5.5, we can rewrite the code below
242
        // to the reducing($name, ...$args) structure.
243
        // http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list
244
        $method = sprintf('\Zicht\Itertools\util\Mappings::%s', $name);
245
        if (!is_callable($method)) {
246
            throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid mapping.', $name));
247
        }
248
        return call_user_func_array($method, array_slice(func_get_args(), 1));
249
    }
250
251
    /**
252
     * Returns a filter closure
@@ 261-272 (lines=12) @@
258
     * @return \Closure
259
     * @throws \InvalidArgumentException
260
     */
261
    public function filtering($name)
262
    {
263
        // note, once we stop supporting php 5.5, we can rewrite the code below
264
        // to the reducing($name, ...$args) structure.
265
        // http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list
266
        $method = sprintf('\Zicht\Itertools\util\Filters::%s', $name);
267
        if (!is_callable($method)) {
268
            throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid filter.', $name));
269
        }
270
        return call_user_func_array($method, array_slice(func_get_args(), 1));
271
    }
272
273
    /**
274
     * Make an iterator that returns values from $iterable where the
275
     * $strategy determines that the values are not empty.