Created
October 18, 2016 12:37
-
-
Save dantleech/82618e89521e85ffd484a67b72d5ea76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Collection implements \IteratorAggregate | |
| { | |
| private $foo; | |
| private $bar; | |
| private $collection; | |
| public function __construct(\Traversable $collection) | |
| { | |
| $this->foo = 'bar'; | |
| $this->bar = 'foo'; | |
| $this->collection = $collection; | |
| } | |
| public function getIterator() | |
| { | |
| return new \ArrayIterator($this->collection); | |
| } | |
| } | |
| $collection = new Collection(new \ArrayObject([ | |
| new \stdClass(), new \stdClass(), new stdClass() | |
| ])); | |
| var_dump(next($collection));die();; | |
| // "foo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment