-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Supplying the $flag parameter to FunctionalInterface::filter(callable $func = null, $flag = null); currently relies on PHP 5.6 constants \USE_KEY and \USE_BOTH to decide whether the callback is called with the value, key or both <value, key>. This functionality should instead be available for all PHP versions supported via composer.json require statement, currently >= 5.5.9.
I see two possible approaches here...
1) Haystack adds its own constants and uses them for filter($func, null $flag = null).
null- Pass value.FunctionalInterface::USE_KEY- Pass key.FunctionalInterface::USE_BOTH- Pass both.
2) Haystack adds two new methods that don't require calling code to provide the flags.
filter($func, null $flag = null)-- Passes container value to callback unless $flag given. $flag can be one ofnull || FunctionalInterface::USE_KEY || FunctionalInterface::USE_BOTH. Return true preserves key => value in new container.filterByKey($func)-- Passes container key to callback. Implementation delegates to filter() and supplies the correct constant. Return true preserves key => value in new container.filterByBoth($func)-- Passes container key as first callback argument, value as second argument. Implementation delegates to filter() and supplies the correct constant. Return true preserves key => value in new container.
Metadata
Metadata
Assignees
Labels
No labels