GithubHelp home page GithubHelp logo

ericpoe / haystack Goto Github PK

View Code? Open in Web Editor NEW
38.0 38.0 1.0 476 KB

Forget Haystack vs Needle order, the object IS the Haystack. Haystack is a library that allows for pipelining and immutable structures.

License: MIT License

PHP 100.00%

haystack's People

Contributors

ericpoe avatar johnkary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

johnkary

haystack's Issues

FunctionalInterface::filter() should support passing keys/both in all PHP versions

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 of null || 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.

Drop 5.6 and 7.0 Support

As PHP has completely dropped support for both 5.6 and 7.0, the library should stay current and move up to 7.1 as a minimum since its the lowest supported version.

The semantics of tail()

Great job on this project. This is a big need in the PHP world.

I'm having a bit of a hard time agreeing that the tail() method is named properly. On at first glance I expected tail to give me the last element of a collection and not everything but the head. I equated it to the unix tail command which (by default) gives you the last 10 lines of a file. Is there a precedent in other languages for a tail() method to do as this project does now?

Lower PHP version constraint to >= 5.5.9

Drupal 8 has a minimum requirement of PHP >= 5.5.9. Drupal developers may be unable to use Haystack if their host only provides the minimum PHP version. Given Drupal's wide appeal could we consider lowering Haystack's minimum requirements to PHP 5.5.9+?

Moving from PHP 5.4 to 5.6 started here: 4a62a0d

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.