Code Duplication    Length = 13-13 lines in 2 locations

src/Zicht/Itertools/filters.php 2 locations

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