Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- final class ListOfId implements \Iterator, \Countable
- {
- private $values;
- public function __construct(array $values = [])
- {
- $this->values = array_values(array_filter(array_unique(array_map('intval', $values))));
- }
- public function count()
- {
- return \count($this->values);
- }
- public function isEmpty()
- {
- return $this->count() > 0;
- }
- public function toArray()
- {
- return $this->values;
- }
- public function current()
- {
- return \current($this->values);
- }
- public function next()
- {
- return \next($this->values);
- }
- public function key()
- {
- return \key($this->values);
- }
- public function valid()
- {
- return \key($this->values) !== null;
- }
- public function rewind()
- {
- return \reset($this->values);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement