2017 © Pedro Peláez
 

library splash

Chainable SPL and custom iterators.

image

wittiws/splash

Chainable SPL and custom iterators.

  • Saturday, February 25, 2017
  • by wittiws
  • Repository
  • 1 Watchers
  • 0 Stars
  • 58 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 5 % Grown

The README.md

Splash

Tested against PHP 5.3/5.4/5.5/HHVM, (*1)

Build Status, (*2)

Splash is a chainable (and therefore concise) way to interact with the SPL iterators., (*3)

```` php // Basic example. \Splash\Splash::mount(); foreach (splash(DIR)->recursiveDirectory()->recursiveIterator()->regex($match) as $path) { }, (*4)


[For more information, visit the project page.](http://www.witti.ws/project/splash) Splash Custom Iterators ----------------------- Splash comes bundles with some iterators that did not make it into SPL. Currently, this includes: ### [InverseRegexIterator](https://github.com/wittiws/splash/blob/master/src/Iterator/InverseRegexIterator.php) This is a simple iterator that excludes any items that match a regular expression. ```` php $dat = splash('a', 'b')->inverseRegex('/a/')->toArray(); // $dat == array('b')

SliceIterator

This is a simple iterator that narrows results to a slice like array_slice()., (*5)

```` php $dat = splash('a', 'b', 'c')->slice(1, 1)->toArray(); // $dat == array('b'), (*6)


### [CallbackIterator](https://github.com/wittiws/splash/blob/master/src/Iterator/CallbackIterator.php) This is an iterator that runs a callback against each element and allows the callback to either return TRUE to retain values (like with CallbackFilterIterator) or to directly manipulate the new iterator. The direct advanced option allows for the splitting of values via the callback. ```` php /** * Callback for CallbackIterator * * @param $current Current item's value * @param $key Current item's key * @param $iterator Iterator being traversed * @param $new_iterator Iterator being built (to allow item splits) * @return boolean TRUE to auto-add the current item to $new_iterator, FALSE otherwise */ function my_callback(&$current, $key, $iterator, &$new_iterator) { $current = 'a'; return TRUE; } $dat = splash('a', 'b', 'c')->callback('my_callback')->toArray(); // $dat == array('a', 'a', 'a')

The Versions

25/02 2017

dev-master

9999999-dev https://github.com/wittiws/splash

Chainable SPL and custom iterators.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

chaining spl iterators