@@ 73-85 (lines=13) @@ | ||
70 | * @return \Closure |
|
71 | * @deprecated Instead use not(in(...)) |
|
72 | */ |
|
73 | function not_in($haystack, $strategy = null, $strict = false) |
|
74 | { |
|
75 | if (!is_bool($strict)) { |
|
76 | throw new \InvalidArgumentException('$STRICT must be a boolean'); |
|
77 | } |
|
78 | if (!is_array($haystack)) { |
|
79 | $haystack = Itertools\iterable($haystack)->values(); |
|
80 | } |
|
81 | $strategy = conversions\mixed_to_value_getter($strategy); |
|
82 | return function ($value, $key = null) use ($haystack, $strategy, $strict) { |
|
83 | return !in_array($strategy($value, $key), $haystack, $strict); |
|
84 | }; |
|
85 | } |
|
86 | ||
87 | /** |
|
88 | * Returns a filter closure that only accepts values that are equal to $EXPECTED |
@@ 60-72 (lines=13) @@ | ||
57 | * @param boolean $strict |
|
58 | * @return \Closure |
|
59 | */ |
|
60 | public static 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 = iterable($haystack)->values(); |
|
67 | } |
|
68 | $strategy = Conversions::mixedToValueGetter($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 equal to $expected |