Code Duplication    Length = 13-13 lines in 2 locations

src/Zicht/Itertools/filters.php 2 locations

@@ 59-71 (lines=13) @@
56
 * @param boolean $strict
57
 * @return \Closure
58
 */
59
function in($haystack, $strategy = null, $strict = false)
60
{
61
    if (!is_bool($strict)) {
62
        throw new \InvalidArgumentException('$STRICT must be a boolean');
63
    }
64
    if (!is_array($haystack)) {
65
        $haystack = Itertools\iterable($haystack)->values();
66
    }
67
    $strategy = conversions\mixed_to_value_getter($strategy);
68
    return function ($value, $key = null) use ($haystack, $strategy, $strict) {
69
        return in_array($strategy($value, $key), $haystack, $strict);
70
    };
71
}
72
73
/**
74
 * Returns a filter closure that only accepts values that are not in $HAYSTACK.
@@ 83-95 (lines=13) @@
80
 *
81
 * @deprecated Instead use not(in(...))
82
 */
83
function not_in($haystack, $strategy = null, $strict = false)
84
{
85
    if (!is_bool($strict)) {
86
        throw new \InvalidArgumentException('$STRICT must be a boolean');
87
    }
88
    if (!is_array($haystack)) {
89
        $haystack = Itertools\iterable($haystack)->values();
90
    }
91
    $strategy = conversions\mixed_to_value_getter($strategy);
92
    return function ($value, $key = null) use ($haystack, $strategy, $strict) {
93
        return !in_array($strategy($value, $key), $haystack, $strict);
94
    };
95
}
96
97
/**
98
 * Returns a filter closure that only accepts values that are equal to $EXPECTED