2017 © Pedro Peláez
 

library iterator-trait

Trait providing methods implementing the Iterator interface.

image

dgifford/iterator-trait

Trait providing methods implementing the Iterator interface.

  • Thursday, October 6, 2016
  • by dgifford
  • Repository
  • 0 Watchers
  • 0 Stars
  • 359 Installations
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 32 % Grown

The README.md

Iterator Trait

Provides methods for implementing the iterator interface allowing objects to be iterated with a foreach loop., (*1)

The trait adds a private property $container to hold the items that are iterated and a private property $position which hold the current position in $container., (*2)

Classes must implement the iterator interface., (*3)

class Foo implements \Iterator
{
    Use IteratorTrait;

    public function add( $item = '' )
    {
        $this->container[] = $item;
    }
}


$this->foo = new Foo;

$this->foo->add( 'zero' );
$this->foo->add( 'one' );
$this->foo->add( 'two' );

foreach( $this->foo as $key => $value )
{
    echo "$key => $value";
}

// 0 => zero
// 1 => one
// 2 => two

The Versions

06/10 2016

dev-master

9999999-dev

Trait providing methods implementing the Iterator interface.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.4

 

php trait array interface iterator interface

06/10 2016

v1.1

1.1.0.0

Trait providing methods implementing the Iterator interface.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.4

 

php trait array interface iterator interface

16/09 2016

v1.0

1.0.0.0

Trait providing methods implementing the Iterator interface.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.4

 

php trait array interface iterator interface