Skip to content

Commit

Permalink
Make Stripe_Util_Set implement IteratorAggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
chadicus committed Aug 6, 2014
1 parent 7f31c53 commit f1e12d7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Stripe/Util/Set.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Stripe_Util_Set
class Stripe_Util_Set implements IteratorAggregate
{
private $_elts;

Expand All @@ -27,9 +27,13 @@ public function discard($elt)
unset($this->_elts[$elt]);
}

// TODO: make Set support foreach
public function toArray()
{
return array_keys($this->_elts);
}

public function getIterator()
{
return new ArrayIterator($this->toArray());
}
}

0 comments on commit f1e12d7

Please sign in to comment.