@@ 32-38 (lines=7) @@ | ||
29 | * @param null|string|\Closure $strategy |
|
30 | * @return \Closure |
|
31 | */ |
|
32 | public static function type($class, $strategy = null) |
|
33 | { |
|
34 | $strategy = Conversions::mixedToValueGetter($strategy); |
|
35 | return function ($value, $key = null) use ($class, $strategy) { |
|
36 | return $strategy($value, $key) instanceof $class; |
|
37 | }; |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Returns a filter closure that only accepts values that are in $haystack. |
|
@@ 217-223 (lines=7) @@ | ||
214 | * @param null|string|\Closure $strategy |
|
215 | * @return \Closure |
|
216 | */ |
|
217 | public static function not($strategy = null) |
|
218 | { |
|
219 | $strategy = Conversions::mixedToValueGetter($strategy); |
|
220 | return function ($value, $key = null) use ($strategy) { |
|
221 | return !($strategy($value, $key)); |
|
222 | }; |
|
223 | } |
|
224 | ||
225 | /** |
|
226 | * Returns a filter closure that only accepts values that match the given regular expression. |