2017 © Pedro Peláez
 

library loopy

A loop library for PHP.

image

enzyme/loopy

A loop library for PHP.

  • Sunday, April 3, 2016
  • by r3oath
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

, (*1)

Build Status Coverage Status Scrutinizer Code Quality, (*2)

A loop library for PHP., (*3)

Installation

Run the following command inside of your project directory., (*4)

composer require enzyme/loopy

Usage

Simple

A simple loop over an array., (*5)

use Enzyme\Loopy\Each;

$array = [1, 2, 3];

Each::shallow()->begin($array, function($bag) {
    echo $bag->value() . ', ';
});

The above will output 1, 2, 3,, (*6)

Deep

A deep loop over a multidimensional array., (*7)

use Enzyme\Loopy\Each;

$array = [1, 2, 3, 4 => [4, 5, 6]];

Each::deep()->begin($array, function($bag) {
    echo $bag->value() . ', ';
});

The above will output 1, 2, 3, 4, 5, 6,, (*8)

Filtered

A loop over a filtered array., (*9)

use Enzyme\Loopy\Each;
use Enzyme\Loopy\Filters\SkipNulls;

$array = [1, 2, null, 4, 5];

Each::deep(new SkipNulls)->begin($array, function($bag) {
    echo $bag->value() . ', ';
});

The above will output 1, 2, 4, 5,, (*10)

Bags

The $bag object passed to the callback function generally contains the follow information., (*11)

Key Value Description
key() Key The enumerable objects key for the given pass.
value() Value The enumerable objects value for the given pass.
cycle() Current cycle (0 based) How many times around the entire object the looper has gone.
depth() Current depth (0 based) The current depth of the pass, for multidimensional arrays.
index() Current index (0 based) The current index, in this case index is really a count of the number of items encountered so far.

Filters

Filter Description
SkipNulls Will skip over any values which are null.
Regex Will test value against the supplied regular expression.
Equal Will test value for equality against the given rule. (===)
Less Will test that value is less than the give rule, or less than or equal if parameter 2 in the constructor is set to true.
Greater Will test that value is greater than the give rule, or greater than or equal if parameter 2 in the constructor is set to true.

The Versions

03/04 2016

dev-master

9999999-dev https://github.com/enzyme/loopy

A loop library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

php loop for enzyme while foreach

03/04 2016

v1.0.0

1.0.0.0 https://github.com/enzyme/loopy

A loop library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

php loop for enzyme while foreach

03/04 2016

dev-bleeding

dev-bleeding https://github.com/enzyme/loopy

A loop library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

php loop for enzyme while foreach

11/12 2015

v0.0.4

0.0.4.0 https://github.com/enzyme/loopy

A loop library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

php loop for enzyme while foreach

10/12 2015

v0.0.3

0.0.3.0 https://github.com/enzyme/loopy

A loop library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

php loop for enzyme while foreach

09/12 2015

v0.0.2

0.0.2.0 https://github.com/enzyme/loopy

A loop library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

php loop for enzyme while foreach

09/12 2015

v0.0.1

0.0.1.0 https://github.com/enzyme/loopy

A loop library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

php loop for enzyme while foreach